Forcing http to https or vice versa

Here’s the code to paste in to the .htaccess file if you need to force a forward from either https to or http to https.

 

Https to Http

RewriteEngine On

RewriteCond %{HTTPS} on
RewriteRule ^(.*)$ http://%{HTTP_HOST}%{REQUEST_URI}

 

Http to Https

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]