How to set nginx to make files in a directory not case sensitive
给我你的怀抱
给我你的怀抱 2017-05-16 17:28:49
0
3
813

The cache is dynamically generated. It is more efficient to read these cache files directly through the URL. However, cache letters are all lowercase. For example http://xxx/ooo/abc.jpg

When the user reads http://xxx/ooo/ABC.jpg, the cache cannot be located (error report

How can I ignore the case of files only in the path ooo/?

给我你的怀抱
给我你的怀抱

reply all(3)
仅有的幸福

I didn’t even read the question clearly, so I posted a link. Unfortunately, I don’t have enough reputation, otherwise I would definitely step on you
Let me answer the poster’s question, two options:
1. Use the Perl Moudle officially provided by nginx. Note that this module is not automatically loaded. When you need to run the configuration file, add --with-httpperlmodule. First, the location must match the ooo directory, and then match the remaining uri. If there are uppercase letters, call perl to convert all urls to lowercase, and then rewrite, refer to the configuration code:

    #测试perl的统一转小写功能
    perl_set    $url '
        sub {
                my $r = shift;
                my $lurl = lc($r->uri);
                return $lurl;
        }
    ';

    location ~* ^/ooo/ {
        if ($uri ~ [A-Z]) {
            rewrite ^(.*)$  $url    premanent;
        }   

        root ooo所在的根目录;
    }

  1. Google found that someone provided a third-party module for nginx. The usage is relatively clear, so I posted the link directly: https://github.com/replay/ngx_http_lower_upper_case
伊谢尔伦

You can use lua, perl for processing, or you can write modules for processing. It has been given above, so I won’t repeat it.

Ty80

http://sookk8.blog.51cto.com/455855/564705

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template