Redirect all HTTP traffic to HTTPS

Have you ever wanted to ensure all your http traffic goes through https instead? I have, and it took me forever to figure out how to do this.

 

These are the exact steps I used to do this on a web server I host, running on the excellent Turnkey LAMP appliance. Thus, it is Debian-based.

 

From the linux shell, type: sudo a2enmod rewrite
restart Apache
sudo nano /etc/apache2/sites-available/000-default.conf
Add the following in the <VirtualHost *:80> config, commenting the existing lines out:
RewriteEngine On
RewriteRule ^(.*)$ https://%{HTTP_HOST}$1 [R=301,L]
restart Apache again.

 

You’re done!

Leave a Reply

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

Facebook Auto Publish Powered By : XYZScripts.com
x Shield Logo
This Site Is Protected By
The Shield →