【问题标题】:How to serve HTTP header 404 with a static html page?如何使用静态 html 页面提供 HTTP 标头 404?
【发布时间】:2012-06-19 17:08:07
【问题描述】:

如何返回 HTTP 标头 404 Not found 并仍然显示静态 html 页面? 我有 ErrorDocument 404 mysite.com/searchmysite/index.html 在 .htaccess 中。 但显然这对 seo 不利。

类似的未回答问题: Can I change the page's HTML status code on the client side?404 header - HTTP 1.0 or 1.1?

【问题讨论】:

  • 你提到的两个问题在我看来都得到了很好的回答......

标签: .htaccess error-handling seo http-headers http-status-code-404


【解决方案1】:

假设您打算将404 错误代码作为您自己的不涉及ErrorDoccument 的自定义HTML 页面的一部分发送,您可以使用服务器端代码 发送404 标头strong> 像 PHP 一样,例如使用header("HTTP/1.0 404 Not Found");。您必须在任何输出之前发送此内容,然后在发送之后输出您的自定义网页。

也没有理由说明ErrorDocument 对 SEO 不利,除非您担心 404 响应,在这种情况下,您不想在第一个发送 404 标头地点

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-09-06
    • 1970-01-01
    • 2018-02-05
    • 2012-09-21
    • 1970-01-01
    • 1970-01-01
    • 2016-09-14
    • 2014-11-12
    相关资源
    最近更新 更多