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

Popular posts from this blog

How to delete cookies in Magento 2?

Magento 2 Events Observer lists

Magento 2 How to Identify Payment method is offline or online after place order