Try_files and location blocks

António P. P. Almeida appa at perusio.net
Fri Jun 24 02:46:36 MSD 2011


On 23 Jun 2011 23h29 WEST, dave at jetcafe.org wrote:

> Thanks very much for looking at this. 
>
> appa at perusio.net writes:
>> Also your later config could be simplified:
>> server {
>> ...
>> location / {
>> try_files $uri $uri/ /error.php?c=404 =404;
>>> 	  
>>>
>
> Where is this "=" notation documented? That try_files line looks
> exactly like what I'm trying to do and appears much more elegant.

http://sysoev.ru/nginx/docs/http/ngx_http_core_module.html#try_files

Use google translate :) Yes it's missing from the wiki :(

> I was under some impression that try_files could not take arguments
> with a URI, which may be an assumption based on the name of the
> directive.  It's not really documented that try_files can do this
> either, unless I'm looking in the wrong place?

It's explicitly stated in the wiki that you *must* specify the args
because in the try_files directive they're not preserved as opposed to
what happens in a rewrite directive.

> http://wiki.nginx.org/CoreModule#try_files
>
> Right?

Yep.

> Finally, exactly what happens if you have location blocks but none
> of them match and you haven't specified a default?

You should get a 404.

--- appa



More information about the nginx mailing list