error_page and named locations

Almir Karic almir at kiberpipa.org
Wed Dec 10 19:28:48 MSK 2008


the problem is that when you request \.php$ the error_page from locatin /
doesn't get executed. to resolve the problem move the error_page directive out
of the location / (directly in server {}).

On Wed, Dec 10, 2008 at 03:52:22PM +0000, cynix wrote:
> cynix <cynix at ...> writes:
> 
> > 
> > But if I used the following:
> > 
> >  location ~ \.php$ {
> > 
> >   error_page 404 = /index.php;
> >  }
> > 
> > Then it will work as intended.
> > 
> 
> Just to clarify, I meant 
> 
>  location ~ \.php$ {
>   fastcgi_pass 127.0.0.1:1234;
>   include fastcgi_params;
>   fastcgi_param SCRIPT_FILENAME /www_root$fastcgi_script_name;
>   fastcgi_param SCRIPT_NAME $fastcgi_script_name;
>   fastcgi_intercept_errors on; 
>   error_page 404 = /index.php;
>  }
> 
> works. I used "..." instead of retyping the whole thing to save a few keystrokes
> but don't know why it didn't show.
> 
> 





More information about the nginx mailing list