Redirecting all pages to https://www…

To simplify URLs on sites I usually like to forward everything to an encrypted connection (HTTPS://) with the www subdomain. Here’s how you setup the Apache .htaccess for this. Just add the following lines to the top of the .htaccess file…

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