https-coverLast week I decided to install Let’s Encrypt SSL and set up HTTPS for the entire site. After activating HTTPS in my hosting’s control panel page, it took me a while (and few failed experiments) to figure out how to actually redirect all traffic to the new HTTPS. I am sure that I am not alone, so I write this article for a guide for you who might need this.
To redirect all traffic to a new address, you need to access your .htaccess file. This is a hidden file located in the folder of your web files when you use FTP to browse your files. You should find a block of setting written by WordPress there. Add these lines ABOVE the WordPress block:

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

The first line simply activates rewrite engine. The second line checks if the address is already using HTTPS. Finally, the last line redirects everything to HTTPS. The R=301 code marks this as permanent change.

That’s it, save the file and upload it back to your live site.