<div><code lang="nginx"></div>if (-f $request_filename) {<div> fastcgi_pass <a href="http://127.0.0.1:9000">127.0.0.1:9000</a>;</div><div>}</div><div></code></div><div><br></div><div>OR:</div><div>
<br></div><div><code lang="nginx"></div><div>if (!-f $request_filename) {</div><div> return 404;</div><div>}</div><div>fastcgi_pass <a href="http://127.0.0.1:9000">127.0.0.1:9000</a>;</div><div></code></div>
<div><br></div><div>The first one is what I current used with my Nginx.</div><div><div><div><br><div class="gmail_quote">On Wed, Jul 1, 2009 at 10:20 PM, Maxim Dounin <span dir="ltr"><<a href="mailto:mdounin@mdounin.ru">mdounin@mdounin.ru</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Hello!<br>
<div class="im"><br>
On Wed, Jul 01, 2009 at 02:52:06PM +0100, Nuno Magalhães wrote:<br>
<br>
> Greetings,<br>
><br>
> If i provide a valid URL, it's processed.<br>
> If i provide an invalid URL, nginx shows the 404 page except it the<br>
> invalid URL ends in .php - in that case i get the "no input file<br>
> specified" message.<br>
<br>
</div>Looks like you've configured passing urls ending with ".php" to<br>
php for processing. So you got errors from php, not from nginx.<br>
It's expected behaviour, no?<br>
<br>
And, actually, "no input file specified" *is* 404 error. It's<br>
just has some fancy php-specific content.<br>
<div class="im"><br>
> I'm in the process of changing my php files to an html extension (i<br>
> assume that would "fix" things), however, i'd like to get a 404<br>
> instead of the message regardless.<br>
><br>
> I tried using "fastcgi_intercept_errors off" in the conf for my server<br>
> (in sites-available), but it didn't do anything (i did restart both<br>
> nginx and the fast-cgi processes).<br>
><br>
> Is there a better way?<br>
<br>
</div>If you want to change error page returned by php to something<br>
pretty-looking, you should:<br>
<br>
1. Use "fastcgi_intercept_errors on;" to instruct nginx to<br>
intercept and change errors returned by fastcgi application.<br>
<br>
2. Make sure you explicitly configured error_page for 404.<br>
Default compiled-in error pages are used only for nginx own<br>
errors, not for fastcgi_intercept_errors/proxy_intercept_errors.<br>
<br>
So your resulting config should look like:<br>
<br>
error_page 404 /404.html;<br>
<br>
location ~ \.php$ {<br>
fastcgi_pass ...;<br>
fastcgi_intercept_errors on;<br>
}<br>
<br>
...<br>
<font color="#888888"><br>
Maxim Dounin<br>
<br>
</font></blockquote></div><br><br clear="all"><br>-- <br>Twitter: <a href="http://www.twitter.com/leechael">http://www.twitter.com/leechael</a><br>
</div></div></div>