【发布时间】:2014-12-30 22:26:26
【问题描述】:
我有一个 apache Web 服务器,它充当内部应用服务器的反向代理。我已经使用 ProxyPass 和 ProxyPassReverse 来实现这一点。我有多个上下文根映射到不同的应用程序。
我正在尝试从一个上下文的域名中删除上下文根,以便用户可以直接以https://mydomain.com 而不是https://mydomain.com/contextRoot 访问该网站。我添加了以下重写规则,而不是为此上下文的 proxypass 和 proxypassreverse 配置。
# redirecting old URL to new URL
RewriteRule ^/contextRoot(.*)$ https://mydomain.com$1 [L,R=301]
# proxying to internal app servers
RewriteCond %{REQUEST_URI} !^(/anotherContextRoot1.*)$
RewriteCond %{REQUEST_URI} !^(/anotherContextRoot2.*)$
RewriteRule .* http://10.1.0.1:8080/contextRoot%{REQUEST_URI} [L,P]
此配置适用于所有 http GET 请求。对于 POST 请求,会发生重定向,但后续调用会变为 GET。
请帮助我了解为什么会发生这种情况以及我该如何纠正。我还想了解是否有任何更多的重写规则配置,我已经添加以执行 proxypassreverse 在以前的配置中使用的操作。
【问题讨论】:
-
同样的问题!
标签: apache mod-rewrite url-rewriting