location block, is this the intended behaviour?

Igor Sysoev is at rambler-co.ru
Thu Nov 5 11:20:48 MSK 2009


On Thu, Nov 05, 2009 at 02:57:00PM +0700, Edho P Arief wrote:

> location /
> {
>    /some/main/root;
> }
> 
> location /blah
> {
>    /some/other/root;
> }
> 
> will result in 404 when accessing www.domain.com/blah123.html even
> though there's /some/main/root/blah123.html (instead it tries
> /some/other/root/blah123.html)

Yes.

> OTOH, using
> 
> location /blah/ { ... }
> 
> will result in 404 when accessing domain.com/blah even though there's
> an index in the location. (probably because it doesn't match)
> 
> of course this works as I wanted it to.
> 
> location ~ /blah($|/) { ... }
> 
> *using try_files $uri $uri/ @fallback doesn't help.
> 
> is this intended?

It's better to use two locations:

   location = /blah {
       ...
   }

   location /blah/ {
       ...
   }

instead of this regex.


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





More information about the nginx mailing list