Force redirect http to https

A simple and very straight forward way to force redirect http requests to https without amending your website code in environments where the server hosting your website is behind a load balancer (such as for most shared hosting/cloud platforms) is by using this piece of code in your .htaccess file:

RewriteEngine On
RewriteCond %{ENV:SSL} !1
RewriteRule ^(.*)$ https://yourdomain.com/$1 [R,L]

Leave a comment

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload the CAPTCHA.