Welcome! Log In Create A New Profile

Advanced

Re: try_files for alias

June 18, 2009 10:40AM
2009/6/18 Igor Sysoev <is@rambler-co.ru>:
> On Wed, Jun 17, 2009 at 09:57:41AM +0700, Edho P Arief wrote:
>
>> How do I make this work?
>>
>> location ~ /~someapp(.*)$ { alias /home/someapp/root$1; try_files $uri
>> /~someapp/err404.htm; }
>>
>> The try_files never catch the $uri (nor $1) and returns 500 (redirection cycle)
>>
>> Am I 'forced' to use error_page in this case?
>>
>> This works:
>>
>> location ~ /~someapp(.*)$ { alias /home/someapp/root$1; error_page 404
>> /~someapp/err404.htm; }
>>
>> and without regex the error_page and try_files seem to be completely ignored:
>> neither
>>     location /~someapp/ { alias /home/someapp/root/; error_page 404
>> /~someapp/err404.htm; }
>> nor
>>     location /~someapp/ { alias /home/someapp/root/; try_files $uri
>> /~someapp/err404.htm; }
>> works.
>
> If request is "/~someapp/one", then this location
>
>    location /~someapp/ {
>        alias     /home/someapp/root/;
>        try_files $uri   /~someapp/err404.htm;
>    }
>
> will test /home/someapp/root/one existence.
>
> As to
>
>    location ~ /~someapp(.*)$ {
>        alias /home/someapp/root$1;
>        try_files $uri /~someapp/err404.htm;
>    }
>
> this "alias" with captures is special case.
> A "root" is always just prefix to URI and "try_files" tests "root$uri".
> An "alias" without captures replaces location part in URI with
> the "alias" value, and "try_files" tests "alias/modified_uri"
> An "alias" with captures replaces a whole URI with the "alias" value,
> and "try_files" tests "alias/$uri", and $uri is surpplus here.
> You need just to pass empty value to "try_files":
>
>    location ~ /~someapp(.*)$ {
>        alias /home/someapp/root$1;
>        try_files ""  /~someapp/err404.htm;
>    }
>

Thanks for the explanation (and it works). It'd be nice to have this
kind of information available in documentation somewhere :)

Or maybe I (or someone else) can update the wiki... (the alias part is outdated)

>
> --
> Igor Sysoev
> http://sysoev.ru/en/
>
>



--
O< ascii ribbon campaign - stop html mail - www.asciiribbon.org
Subject Author Posted

try_files for alias

edogawaconan June 16, 2009 10:57PM

Re: try_files for alias

edogawaconan June 16, 2009 11:35PM

Re: try_files for alias

edogawaconan June 18, 2009 09:08AM

Re: try_files for alias

andor.toth April 09, 2013 10:04AM

Re: try_files for alias

Igor Sysoev June 18, 2009 10:10AM

Re: try_files for alias

edogawaconan June 18, 2009 10:40AM

Re: try_files for alias

edogawaconan June 19, 2009 04:30AM

Re: try_files for alias

edogawaconan June 19, 2009 04:33AM

Re: try_files for alias

edogawaconan June 19, 2009 10:52AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 272
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready