【发布时间】:2013-09-22 03:18:53
【问题描述】:
我通过.htaccess 配置了我的网站来执行此操作:
ErrorDocument 403 http://www.mydomain.com/error.php?e=403
ErrorDocument 401 http://www.mydomain.com/error.php?e=401
ErrorDocument 400 http://www.mydomain.com/error.php?e=400
ErrorDocument 500 http://www.mydomain.com/error.php?e=500
error.php 记录错误并显示用户/客户友好的错误页面。
另外,我添加了这段代码:
if($_GET['e'] == '404' || $_GET['e'] == '403' || $_GET['e'] == '500' )
{ $error_no = $_GET['e']; } else { $error_no = '200'; }
header(' ', true, $error_code);
所以当我访问mydomain.com/pagedoesnotexist 时,我看到错误页面(但地址栏仍然显示不存在的 URL),我收到一个报告说 404 页面被触发,但我查看了我的服务器日志文件,这就是它所说的:
MY.IP.000.00 - - [date and time] "GET /pagedoesnotexistHTTP/1.1" 200 2450 "-" "USERAGENTINFO"
在我的服务器日志中,我看不到任何关于 404 的信息……只有 200……这是为什么呢?我怎样才能让它发回 404 代码? 现在我假设机器人等总是得到 200,这意味着访问不存在的网站时可以得到响应......或者我错过了什么?
*题外话:2450 代表什么? O_o*
【问题讨论】:
标签: php .htaccess http-headers httpresponse errordocument