Using .htaccess to migrate to https

If you change your website from http to https, it’s usually a bigger problem due to the users that didn’t update their bookmarks or just ignore the new links you sent them in an email announcement again and again. But there is a pretty simple way thanks to mod-rewrite of the apache webserver. Just add those few lines to your .htaccess or vhost config:

RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*) https://%{SERVER_NAME}/$1 [R,L]

This redirects any incoming http connection to the same site using https. If it’s done that way, people won’t even really notice that they are using a secured connection (if the certificate is valid)

You may also like...

Leave a Reply

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

Notify me of followup comments via e-mail. You can also subscribe without commenting.