Redirect request with POST data using .htaccess
RewriteEngine on
RewriteCond %{SERVER_PORT} !443
RewriteCond %{REQUEST_URI} string_to_match_in_url
RewriteCond %{REQUEST_METHOD} POST
RewriteRule ^(.*)$ https://%{HTTP_HOST}/$1 [L,R=307]
The first RewriteCond checks if the request is NOT coming as HTTPS, otherwise it will go in endless loop. If yes, the second RewriteCond checks if the URL contains a string we are looking for. Then if that URL is being submitted as POST method. If everything matches, then we redirect the request using HTTPS secure protocol retaining the POST method and the associated data.
Comments
Post a Comment