How to Force HTTPS using .htaccess file

Website Security is something that no one can debate about because it is paramount unless the site is not legit. So it is important you ensure that your website is always secure by INSTALLING AN SSL

Now, when you install SSL it does not just end there because the website will still operate with a HTTP connection. HTPPS on the other hand ensures encryption and security of your website’s data.

In this guide we will show you how to force HTTPS using the .htaccess file.

Among others .htaccess is responsible for performing the 301 redirects, which permanently redirects an old URL to a new one.

  1. Login to the Cpanel and click File Manager.
  2. Click on the root folder of your domain. If it is the main domain click the public_html folder and locate .htaccess. If you can’t locate it, make sure to create or unhide it.
  3. Right-click on it and click on edit to open it.
  4. Insert the following lines of code below it:

RewriteEngine On

RewriteCond %{HTTPS} off

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

  1. Save the changes.

Was this article helpful?

Leave A Comment?