case insensitive

Boris Dolgov boris at dolgov.name
Thu Jul 29 11:45:23 MSD 2010


On Thu, Jul 29, 2010 at 10:47 AM, Igor Sysoev <igor at sysoev.ru> wrote:
> On Wed, Jul 28, 2010 at 11:26:24PM -0700, Eire Angel wrote:
>> I need to serve images to be case insensitive.
>> too many of the external links were created using the incorrect case for me to
>> just create redirects for them all
>> I am trying to use :
>> location ~* ^.+.(jpg|jpeg|gif|png)$ {
>>  root              /var/www/my_app/current/public/images;
>> access_log        off;
>> expires           30d;
>> }
>>
>> i have also tried using :
>> location ~* ^/images/$ {}
>> with the same results.  please help
>
> nginx does not support case insensitive file access on a case sensitive file
> system. Theoretically this can be implemented, however, it requires
> a lot of overhead: instead of single open() syscall, nginx has to call
> opendir()/readir()/closedir() which involve about ten syscalls. Although
> frequently requested files can be cached in open_file_cache.
You can also try renaming all your images to lowercase and then use
something like this:
location ~* (?P<name>.*)\.(?P<ext>jpg|jpeg|gif|png)$
{
    perl_set new_name 'sub { my $r = shift; return lc($r->variable("name"); }'
    perl_set new_ext 'sub { my $r = shift; return lc($r->variable("ext"); }'
    try_files $new_name.$new_ext /404error;
}

-- 
Boris Dolgov.



More information about the nginx mailing list