Permanent redirect to https

This is a bit of a follow-on from my previous post, in which I was setting up https access on my website.

Once you’ve got https set up correctly, you might, like I did, want to make sure that all traffic to your website now goes the the SSL connection, rather than through an unencrypted connection.

On Linux hosting, like I have with Quadra Hosting, this can easily be done by creating a ‘.htaccess’ file. Create one in the root level of your hosted directory (the one where you have your index.html file). In the .htaccess file, put in the following lines:

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

This will redirect all traffic to the SSL connection.