I have Apache installed on my server and I need to redirect from http to https. The reason for this is our load balancer solution cannot hand https so requests come in on http and then we transfer them to https using the below lines in the httpd.conf file.
<VirtualHost 10.1.2.91:80> Redirect 302 /GladQE/link https://glad-test.com/GladQE/link.do </VirtualHost>
This works fine for GET requests but POST requests will lose the parameters passed on the URL. What would be the easiest way to perform this redirect and maintain POST params?
I need to get from http://glad-test.com/GladQE/link.do to here https://glad-test.com/GladQE/link.do maintaining POST params
Thanks
Tom
Standard Apache redirects will not be able to handle POST data as they work on the URL level. POST data is passed in the body of the request, which gets dropped if you do a standard redirect.
For instance, a POST request should be repeated using another POST request. Show activity on this post. Standard Apache redirects will not be able to handle POST data as they work on the URL level. POST data is passed in the body of the request, which gets dropped if you do a standard redirect.
The Redirect directive lets you execute simple and one-page redirects with Apache. It connects an old URL with a new one by asking the client to fetch the resource again at the new location. The Redirect directive requires at minimum two arguments: the old URL and the new URL.
No rediect 30x preserves post parameters Using 301 redirects for general URL rewriting is not the way to go. This is a performance issue (especially for mobile, but also in general), since it doubles the number of requests for your page. Think about using a URL rewriting tool like Tuckey's URLrewriteFilter or apache mod_rewrite.
You can try with the HTTP status code 307, a RFC compilant browser should repeat the post request. Reference: http://en.wikipedia.org/wiki/List_of_HTTP_status_codes
In contrast to how 302 was historically implemented, the request method is not allowed to be changed when reissuing the original request. For instance, a POST request should be repeated using another POST request.
To change from 302 to 307, do that:
<VirtualHost 10.1.2.91:80> Redirect 307 /GladQE/link https://glad-test.com/GladQE/link.do </VirtualHost>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With