cynix cynix at
Mon Jan 19 19:47:33 MSK 2009

Igor Sysoev <is at ...> writes:

> Changes with nginx 0.7.31                                        19 Jan 2009
>     *) Change: now the "try_files" directive tests files only and ignores 
>        directories.

This seems to cause problems with index.php inside directories. For example:

 index index.php;
 location / {
  try_files $uri @php;
 location @php {
  fastcgi_pass ...;
  fastcgi_param SCRIPT_FILENAME $document_root/index.php;
 location ~ \.php$ {
  fastcgi_pass ...;
  fastcgi_param SCRIPT_FILENAME $document_root$uri;

With 0.7.30 if you request ,
$document_root/test/index.php is served. However with 0.7.31,
$document_root/index.php is served.

And if you do this:

 try_files $uri $uri/index.php @php;

then nginx will serve index.php as a static file, without passing it to FastCGI.
I know this is the intended behavior, as internal rewrite is only issued for the
last parameter of try_files. So how should we let try_files detect index.php
inside a directory if directories are ignored?

More information about the nginx mailing list