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!

x  Powerful Protection for WordPress, from Shield Security
This Site Is Protected By
Shield Security