使用 [P] 代理标志重写 .htaccess

发布于 2024-09-18 23:37:10 字数 300 浏览 4 评论 0原文

我正在尝试通过 .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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

执手闯天涯 2024-09-25 23:37:11

如果 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 server mod_proxy_http is not enabled, which leads to an internal server error when mod_proxy tries to handle the request passed to it by mod_rewrite.

mod_proxy itself is enabled and probably working like you said, since if you don't have it enabled, use of the P 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文