<div>&lt;code lang=&quot;nginx&quot;&gt;</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>&lt;/code&gt;</div><div><br></div><div>OR:</div><div>

<br></div><div>&lt;code lang=&quot;nginx&quot;&gt;</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>&lt;/code&gt;</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">&lt;<a href="mailto:mdounin@mdounin.ru">mdounin@mdounin.ru</a>&gt;</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>
&gt; Greetings,<br>
&gt;<br>
&gt; If i provide a valid URL, it&#39;s processed.<br>
&gt; If i provide an invalid URL, nginx shows the 404 page except it the<br>
&gt; invalid URL ends in .php - in that case i get the &quot;no input file<br>
&gt; specified&quot; message.<br>
<br>
</div>Looks like you&#39;ve configured passing urls ending with &quot;.php&quot; to<br>
php for processing.  So you got errors from php, not from nginx.<br>
It&#39;s expected behaviour, no?<br>
<br>
And, actually, &quot;no input file specified&quot; *is* 404 error.  It&#39;s<br>
just has some fancy php-specific content.<br>
<div class="im"><br>
&gt; I&#39;m in the process of changing my php files to an html extension (i<br>
&gt; assume that would &quot;fix&quot; things), however, i&#39;d like to get a 404<br>
&gt; instead of the message regardless.<br>
&gt;<br>
&gt; I tried using &quot;fastcgi_intercept_errors off&quot; in the conf for my server<br>
&gt; (in sites-available), but it didn&#39;t do anything (i did restart both<br>
&gt; nginx and the fast-cgi processes).<br>
&gt;<br>
&gt; 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 &quot;fastcgi_intercept_errors on;&quot; 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>