为什么不是在Apache显示404错误,当我发送404头用PHP? [英] Why doesn't apache show a 404 error when I send a 404 header with php?
问题描述
我有一个标题('HTTP / 1.0 404未找到');
某处沿code,但它不重定向到Apache默认的404页出于某种原因。
I have a header('HTTP/1.0 404 Not Found');
somewhere along the code but it doesn't redirect to the Apache's default 404 page for some reason.
我对每一个请求到index.php重定向.htaccess文件重写规则。莫非是这个问题?
I have a Rewrite Rule on the .htaccess file that redirects every request to index.php. Could that be the problem?
推荐答案
标题是不是告诉Apache来显示它的404页。相反,在的阿帕奇显示其404页,它发送一个404头与它一起。头是为了有意义的的浏览器的,而不是服务器。阿帕奇显示404时,它无法找到正确的文件显示。既然你的PHP脚本是,阿帕奇已经发现它可以显示,因此不会显示它自己的404页的文件。
The header is not what tells Apache to display it's 404 page. Rather, when Apache displays its 404 page, it sends a 404 header along with it. The header is meant to have meaning to the browser, not the server. Apache displays a 404 when it can't find the proper file to display. Since you're in a PHP script, Apache has already found a file it can display, and thus won't show its own 404 page.
这篇关于为什么不是在Apache显示404错误,当我发送404头用PHP?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!