![如何防止apache ErrorDocument传递路径信息?](https://linux22.com/image/601056/%E5%A6%82%E4%BD%95%E9%98%B2%E6%AD%A2apache%20ErrorDocument%E4%BC%A0%E9%80%92%E8%B7%AF%E5%BE%84%E4%BF%A1%E6%81%AF%EF%BC%9F.png)
我正在尝试将对特定主机名的所有请求转发到特定的 URL。
我的虚拟主机条目如下所示:
<VirtualHost *:80>
ServerName test.example.com
RedirectPermanent / http://another.example.com/path/
</VirtualHost>
这对任何想要http://test.example.com。我正在尝试添加一个错误处理程序:
ErrorDocument 404 http://another.example.com/path/
这样所有请求都会发送到同一个服务器。问题是如果我请求http://test.example.com/foo那么最终结果是请求http://another.example.com/path/foo。我尝试将错误文档设置为http://another.example.com/path? 但它忽略了 ? 并仍然重定向到 /path/foo
如何防止路径被添加到错误 URL?
答案1
也许您只需要RedirectMatch permanent ^ http://another.example.com/path/
RedirectPermanent 或 ErrorDocument。