Force HTTPS redirection
Author: admin admin Reference Number: AA-00421 Views: 53318 Created: 2015-12-23 10:17 Last Updated: 2017-09-04 14:46 0 Rating/ Voters

Question : How do I force redirection from http to https on premium or free hosting.

Answer : in your sites .htaccess file add the following lines :

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

You may use the following lines to force both HTTPS and WWW :

RewriteEngine On
RewriteCond %{ENV:HTTPS} !on [OR]
RewriteCond %{HTTP_HOST} !^www.YOURDOMAIN.COM$ [NC]
RewriteRule ^(.*)$ https://www.YOURDOMAIN.COM/$1 [L,R=301]

Quick Jump Menu