I have an apache web server that acts as a reverse proxy to internal app servers. I have used ProxyPass and ProxyPassReverse to achieve this. I have multiple context roots mapping to different applications.
I am trying to remove the context root from the domain name for one context so that users can access the website directly as https://mydomain.com instead of https://mydomain.com/contextRoot. I have added the following rewrite rules instead of the proxypass and proxypassreverse configurations for this context.
# 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]
This configuration works well for all http GET requests. For POST requests, the redirect happens, but the subsequent call becomes a GET.
Please help me understand why this happens and how can I correct this. I also want to understand is there any more rewrite rule configuration that I have add to do what proxypassreverse used to do in the previous configuration.
I had the same issue and checked a little more. This question is answered in another post:
redirectmatch changes post to get
This question is answered here https://softwareengineering.stackexchange.com/questions/99894/why-doesnt-http-have-post-redirect/99966#99966 - a short summary from this answer