redirectmatch changes post to get

.htaccess, redirect

Solution

A redirect response from your server for whatever request you made, regardless of it being POST or GET request, always results in your client making a GET request (unless you somehow enable it to NOT automatically follow redirects--sometimes I do this with curl, but I don't know any widely used browsers with this functionality available easily to the user). The client browser takes the URL provided by the redirect and treats it as a URL to perform a GET request. No way around it, the POST data is discarded by the server since it was intended for the server resource at the original URL.

If you redirect outside of .htaccess, say in a PHP file to construct redirect response, your only option is to convert the POST parameters into a string of GET parameters and add it to the end of the URL you send back to the client with your redirect response.

I'm fairly confident there is not a way to do automatic POST parameter appending to redirect in the .htaccess file or in the httpd.conf files whether you use the redirect directive or the rewrite directive via the mod_rewrite module.

Problem

I have two separated vhost. On the www. one, I have instaled this only line on .htaccess ``` redirectMatch 301 ^(.*)$ http://d_blur_blur_s.com$1 ``` All works as expected except that in the case where the POST is converted to GET. Please notice that the post has parametres as a get (i didn't do it, and I won't change it) i am just trying to avoid duplicated content. I am showing firebug trace. I expect to have the POST redirected on the main domain with redirectmatch or other trick. Update I have half of the internal links on the site written with www and the other half without it. So I need to keep both public but not duplicated. I need the GETs forwarded as GETs and the POSTs frowarded as POSTs. the problem is big, I have 12000 pages indexed, and lot of forms. So I am first searching for a generic solution without changing code. I full control de server. Thanks a lot

Original source