How To Use .Htaccess To Force SSL On Your Website
Posted by Daniel Naval on 11 May 2019 12:30 PM

Forcing an HTTPS (SSL) Connection on your website is one of the things that you can do with an .htaccess file. This encrypts the connection between your browser and the web server. You require an SSL Certificate for this to work. To know more about SSL Certificate, please click here.

To create or edit an .htaccess file, you need to login to your cPanel account. (Don’t know how to login to your cPanel account? Click here)

Locate your .htaccess file and edit to add the SSL rule to the file.

Add the following lines within the .htaccess file in your website’s root folder.

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



After the edit, just save and close the file.



To test if the change took effect, just open your website and the “Secure” message with lock icon should appear then your url should also show “https”.