Wednesday, March 5, 2008

Redirecting to non-SSL traffic to SSL

To make http:// or http://www. redirect to https:// or https://www. when you have an SSL certificate installed add the following lines in a .htaccess file:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}

Place the .htaccess in the htdocs directory for the corresponding site. Be careful not to overwite an existing .htaccess file.

No comments: