1

对于我的错误文档,我使用的是单个错误页面 (error.html),我将其重定向到使用

ErrorDocument xxx http://www.example.com/error.html?error=xxx

这很好用,我对每个 4xx 和 5xx 错误代码都做同样的事情,'error=xxx' 查询字符串实际上定义了页面的外观(根据遇到的错误显示的文本)。

我还需要捕获在 ErrorDocument 重定向发生之前输入的 URL,并将其作为另一个查询字符串附加到 ErrorDocument 位置

ErrorDocument xxx http://www.example.com/error.html?error=xxx**&url=yyy**

我能做到吗?我知道我在某处读到过使用 PHP 是可能的,但我正在为这个网站避免使用 PHP(当我尝试时它实际上并没有按预期工作)。

我看过类似的问题,但找不到对我有帮助的问题。

4

1 回答 1

1

删除http://fromErrorDocument以避免重定向错误情况,如下所示:

ErrorDocument 404 /error.html?error=404
ErrorDocument 500 /error.html?error=500
...

由于浏览器 URI 不会改变,因此输入的 URI 与REQUEST_URI您的一样可用。error.html

于 2013-12-08T08:19:01.467 回答