【问题标题】:With static content: Apache custom 404 page that returns 404 error带有静态内容:返回 404 错误的 Apache 自定义 404 页面
【发布时间】:2013-03-01 09:03:01
【问题描述】:

我和Apache custom 404 page that returns 404 error有同样的问题,但另外我使用的是html文件,没有脚本语言。

是否可以配置 Apache,使其在浏览器请求时返回具有 404 状态的页面 www.example.com/404.html?

【问题讨论】:

    标签: apache http-status-code-404 static-html


    【解决方案1】:

    我自己给出一个答案,我不确定它是否应该是评论。

    我意识到我试图解决一个变通办法,而不是一个实际问题。最初我想显示一个 404 页面使用

    ErrorDocument 404 /subdirlevel1/404.html
    

    但是,错误文档本身使用了相对路径,因此它仅在请求文档的路径位于正确的子目录级别时才有效。我的意思是:

    http://example.com/subdirlevel1/nonexisting.html
    

    将生成正确的 404 文档,因为 css 样式表的路径位于正确的相对路径中。不过

    http://example.com/subdirlevel1/subdirlevel2/nonexisting.html
    

    行不通。我通过在 404.html 中使用绝对路径解决了这个问题

    按照我在我的问题中尝试过的方式进行操作会很糟糕,因为对现有文件的请求并正确交付该文件不应导致 404,而是 200。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-07-29
      • 2018-04-05
      • 2013-05-07
      • 2011-05-17
      • 1970-01-01
      • 2015-12-28
      • 2016-04-25
      • 2013-09-16
      相关资源
      最近更新 更多