Categories
Uncategorized

HTTP to HTTPS Redirection in .htaccess file

Take backup of .htaccess file

cp .htaccess .htaccess`date +%d%b%Y`

Add this code to .htaccess

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.example.com/$1 [L,R=301]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://www.example.com/$1 [L,R=301]

Done