首页 文章

在 apache httpd 中完成 URL 重写时,POST 请求转换为 GET

提问于
浏览
5

我有一个 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 以前的配置中做了什么。

2 回答

相关问题