POST request gets conversion to GET when url rewriting is done in apache httpd

I have an Apache web server that acts as a reverse proxy for internal application servers. I used ProxyPass and ProxyPassReverse for this. I have multiple mapping of context roots for different applications.

I am trying to remove the context root from the domain name for a single context so that users can directly access the website as https://mydomain.com https://mydomain.com/contextRoot . I added the following rewrite rules instead of 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, a redirect occurs, but the subsequent call becomes GET.

Please help me understand why this is happening and how I can fix it. I also want to understand if there is any other reformatted rule configuration that I am adding to do what was previously done in the previous configuration.

+3


source to share


2 answers


This question will be answered by https://softwareengineering.stackexchange.com/questions/99894/why-doesnt-http-have-post-redirect/99966#99966 - a summary of this answer



HTTP 1.1 actually has a status code (307) that indicates that the request should be retried using the same method and post data.

As others have said, there is potential for abuse here and this could be the reason many frameworks adhere to 301 and 302 in their abstractions.

+2


source


I had the same problem and checked a little more. This question was answered by another post:



redirectmatch changes the message to receive

0


source







All Articles