nginx-0.7.31
Igor Sysoev
is at rambler-co.ru
Tue Jan 20 10:46:02 MSK 2009
On Tue, Jan 20, 2009 at 02:32:27AM +0000, cynix wrote:
> 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?
This is a bug in 0.7.31, I will fix it soon.
As to your configuraiton, you should use:
location ~ (/|\.php)$ {
- if (!-f $document_root$fastcgi_script_name) {
- rewrite ^ @php last;
- }
+ try_files $uri $uri/index.php @php;
fastcgi_pass ...;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
--
Igor Sysoev
http://sysoev.ru/en/
More information about the nginx
mailing list