Force HTTPS via .htaccess file

After installing an SSL certificate, your website is available over HTTP and HTTPS. However, it’s better to use only the latter because it encrypts and secures your website’s data and is also good for your SEO. This tutorial will show you how.

Forcing HTTPS on All Traffic

One of the many functions you can perform via .htaccess is the 301 redirects, which permanently redirects an old URL to a new one. You can activate the feature to force HTTPS on all incoming traffic by following these steps:

1. Go to File Manager in your hosting panel and open .htaccess inside the public_html folder.

If you can’t locate it, you can create a file from scratch named .htaccess and insert all 3 lines in it.

If the file exists find the RewriteEngine On line and insert only line 2 and 3 below it:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

2. Save the changes.

3. Done.

IMPORTANT: Please be aware that to get a SSL certificate you can use Let’s Encrypt (option that is available for free with all of Web Hosting plans) or buy a SSL Certificate starting 6.99 Euro/Year from here.