No input file specified. 解决办法

正常网站,请求不存在的页面,出现No input file specified. 的解决办法,原因是nginx没有开启404跳转

nginx 配置了地址重写

if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php?_url=/$1 last;
}

然后将所有php求情转到php去,
这时如果请求的是php页面,nginx就没有进行重写直接转到php去了,比如请求:/a.php
这时,php返回:

No input file specified

此时,nginx直接将结果返回到页面去了,查看nginx配置,发现没有设置错误页跳转功能,于是在nginx的server中加上:

error_page   404 = http://www.xxx.com/404.html;

果断加上,重启nginx后,发现还是没有跳转。。。

再次查找问题原因,发现原来nginx没有开启错误跳转功能,于是再在nginx的http配置中加上:

fastcgi_intercept_errors on;

重启查看结果,No input file specified不再返回,而是调到指定的 http://www.xxx.com/404.html页面去了,问题解决

作者: 二皮

Hackers please go away