redirect http and non www to https and www using htaccess


Placing this in the .htaccess file to redirect http and non www to http and www

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

RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Leave a comment

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