Friday, 22 January 2010

How to redirect non ssl (http links) traffic to SSL (https links)

Our Level I techs often gets tickets like how to make http:// or http://www. redirect to https:// or https://www. Often the answer is simple, but for the newbies and yours use, I am putting it here.

First requirement is to have an SSL certificate installed. Add the following lines in a .htaccess file:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

I assume when you directly access https://www.domainname.com , the site loads fine.

No comments:

Post a Comment