SSL-1How to redirect HTTP traffic to HTTPS using an .htaccess file

If you have SSL activated on your server it could be a good idea to redirect all the traffic from i.e. –> The traffic over SSL is much safer and your visitors won’t have to write the whole “https:// in front of “www”. This will potentially generate more traffic to to your site. The .htaccess directive works on Windows Servers as well.

1. Go to your web server and find the folder that contains your website
2. At the top of the file list you should have a file called .htaccess
3. if you don’t have that file you can just create it
:~$ sudo nano /var/www/path-to-your-website-folder/.htaccess
4. Add the code below and it will redirect any traffic destined for http//: to https://
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]

From now on, all your incoming traffic will redirect to “https://”.

 Pro tip

If you are looking for a cheap and good SSL certificate we can recommend this one. Only 4.95€ / year! Follow these instructions to set it up.