使用 [P] 代理标志重写 .htaccess
我正在尝试通过 .htaccess 和代理标志进行不可见(透明?)重写。它适用于 [R] 标志,但不适用于 [P] 标志,因为它只给出 500 错误。这两个域位于不同的服务器上,并且启用了 mod_proxy 模块。我的 .htaccess 正确吗?
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} =one.com
RewriteRule ^(.*)$ http://two.com/$1 [P]
I am trying to do an invisible (transparent ?) rewrite via .htaccess and the proxy flag. It works with the [R] flag but not with the [P] flag because it just gives a 500 error. The two domains are on separate servers and the mod_proxy module is enabled. Is my .htaccess correct?
Options +FollowSymLinks
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} =one.com
RewriteRule ^(.*)$ http://two.com/$1 [P]
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果
mod_proxy
被编译为共享模块,则还要求您显式加载相关子模块。您的服务器上可能未启用mod_proxy_http
,这会在mod_proxy
尝试处理mod_rewrite
传递给它的请求时导致内部服务器错误>。mod_proxy
本身已启用,并且可能像您所说的那样工作,因为如果您没有启用它,则使用P
标志只会生成 404 响应。尽管没有错误日志,但很难确定,因此您可能需要找到有权访问该日志的人来查看发生了什么,以帮助您解决问题。If
mod_proxy
was compiled as a shared module, it requires that you explicitly load the relevant submodules too. It's possible that on your servermod_proxy_http
is not enabled, which leads to an internal server error whenmod_proxy
tries to handle the request passed to it bymod_rewrite
.mod_proxy
itself is enabled and probably working like you said, since if you don't have it enabled, use of theP
flag will just generate a 404 response. It's hard to know for sure though without the error log, so you may need to find someone with access to it to see what's going on to help you resolve the problem.