try_files behaviour details

Michael Shadle mike503 at gmail.com
Tue Aug 17 03:12:36 MSD 2010


i have try_files outside of location blocks plenty.

the wiki probably just needs updating

On Mon, Aug 16, 2010 at 1:07 PM, Ensiferous <nginx-forum at nginx.us> wrote:
> Hey,
>
> I have a question about how try_files works in some cases. The standard
> case seems to be
>
> server {
>        server_name foo;
>
>        location / {
>                try_files $uri index.html;
>        }
> }
>
> Here nginx tries $uri and then finally index.html if no other location
> block matches. Now say that there are no other location blocks and nginx
> enters location / again, the try_files directive is then skipped as it's
> already been used once, right?
>
> Second example:
>
> server {
>        server_name bar;
>
>        try_files $uri index.php;
> }
>
> Here try_files is used in the server block. The wiki says try_files
> can't be used here but Nginx will happily accept it, from my testing it
> seems to behave identically to the first example except it's always
> executed. Is this a correct assumption?
>
> Posted at Nginx Forum: http://forum.nginx.org/read.php?2,120447,120447#msg-120447
>
>
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://nginx.org/mailman/listinfo/nginx
>



More information about the nginx mailing list