【问题标题】:Is it possible to use apaches ErrorDocument 404 to actually change the URL instead of needing absolute paths?是否可以使用 apaches ErrorDocument 404 来实际更改 URL 而不是需要绝对路径?
【发布时间】:2011-11-13 20:58:11
【问题描述】:

我们在一个 htaccess 文件中:

ErrorDocument 404 /404.shtml

这可以显示 404.shtml 文件。问题是当有人键入 thedomain.com/folder1/folder2 时,它会破坏布局,因为页面使用的是相对路径而不是绝对路径。我知道我可以使用绝对路径来解决这个问题,但我想知道是否有一种方法可以实际更改 404.shtml 的路径,因此可以保留相对路径。

提前致谢。

【问题讨论】:

    标签: apache http-status-code-404 errordocument


    【解决方案1】:

    经过大量研究,最好还是使用绝对路径。这可以通过重写和编码标头以返回 404 来实现,但是如果可以简单地使用绝对路径来完成,那就不值得了。

    【讨论】:

      【解决方案2】:

      您可以将ErrorDocument 指向一个URL。 Apache 将生成一个重定向。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-10-17
        • 2016-11-14
        • 1970-01-01
        • 1970-01-01
        • 2014-05-13
        • 1970-01-01
        相关资源
        最近更新 更多