nginx-0.7.31

cynix cynix at cynix.org
Tue Jan 20 05:32:27 MSK 2009


Igor Sysoev <is at ...> writes:

> 
>   location ~ (/|\.php)$ {
>       fastcgi_pass ...;
>       fastcgi_index index.php;
>       fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
>   }
> 

This works for the most part, but if I implement a try_files alternative 
within the location block like this:

 location ~ (/|\.php)$ {
  if (!-f $document_root$fastcgi_script_name) {
   rewrite ^ @php last;
  }
  fastcgi_pass ...;
  fastcgi_index index.php;
  fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
 }

Then nginx will segfault when example.com/test/ is requested. 
So I can only do this:

 location ~ (/|\.php)$ {
  if (!-e $document_root$uri) {
   rewrite ^ @php last;
  }
  fastcgi_pass ...;
  ...
 }

But this doesn't take care of the case where index.php doesn't exist 
inside a directory. Is $fastcgi_script_name not properly set when 
used as "if" condition?






More information about the nginx mailing list