自定义404页面发送200状态代码

des*_*ing 0 php http-status-codes http-status-code-404

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

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

我的客户说,它应该给404.

Gum*_*mbo 5

我想你使用ErrorDocument绝对URL,如:

ErrorDocument 404 http://example.com/err404.html
Run Code Online (Sandbox Code Playgroud)

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

请尝试仅使用绝对URL路径:

ErrorDocument 404 /err404.html
Run Code Online (Sandbox Code Playgroud)