404 instead of "no inout file specified"?

Maxim Dounin mdounin at mdounin.ru
Wed Jul 1 18:20:46 MSD 2009


Hello!

On Wed, Jul 01, 2009 at 02:52:06PM +0100, Nuno Magalhães wrote:

> Greetings,
> 
> If i provide a valid URL, it's processed.
> If i provide an invalid URL, nginx shows the 404 page except it the
> invalid URL ends in .php - in that case i get the "no input file
> specified" message.

Looks like you've configured passing urls ending with ".php" to 
php for processing.  So you got errors from php, not from nginx.  
It's expected behaviour, no?

And, actually, "no input file specified" *is* 404 error.  It's 
just has some fancy php-specific content.

> I'm in the process of changing my php files to an html extension (i
> assume that would "fix" things), however, i'd like to get a 404
> instead of the message regardless.
> 
> I tried using "fastcgi_intercept_errors off" in the conf for my server
> (in sites-available), but it didn't do anything (i did restart both
> nginx and the fast-cgi processes).
> 
> Is there a better way?

If you want to change error page returned by php to something 
pretty-looking, you should:

1. Use "fastcgi_intercept_errors on;" to instruct nginx to 
intercept and change errors returned by fastcgi application.

2. Make sure you explicitly configured error_page for 404.  
Default compiled-in error pages are used only for nginx own 
errors, not for fastcgi_intercept_errors/proxy_intercept_errors.

So your resulting config should look like:

    error_page  404  /404.html;

    location ~ \.php$ {
        fastcgi_pass ...;
        fastcgi_intercept_errors on;
    }

    ...

Maxim Dounin





More information about the nginx mailing list