0

404错误页面的200 OK标题错误:

服务器响应:
http ://www.example.com/err404.html HTTP
状态码:HTTP/1.1 200 OK

我的客户说,它应该给出 404。

4

2 回答 2

8

我猜您使用ErrorDocument的是绝对 URL,例如:

ErrorDocument 404 http://example.com/err404.html

在这种情况下,服务器会以http://example.com/err404.html作为位置的 302 重定向进行响应。如果随后请求该 URL,您的服务器将发送您所经历的 200 状态代码。

请尝试使用绝对 URL 路径:

ErrorDocument 404 /err404.html
于 2010-01-04T22:18:41.617 回答
4

如果错误页面是实际请求,您将获得状态 200(即错误页面是由浏览器地址栏、书签、PHP 中的重定向等直接请求的)。如果错误页面是由网络服务器本身返回的,而实际上存在无效请求的方式,或者当它被 PHP 与header("HTTP/1.1 404 Not Found");. 在 Apache HTTP 服务器中,自定义错误页面的位置可以在httpd.conf.

于 2010-01-04T22:14:09.080 回答