How to Force HTTPS using ․htaccess

To force visitors to your website through SSL (HTTPS) page by adding this code in your website’s ․htaccess file.

You can create or edit the ․htaccess file either via FTP, or using with the File Manager in cPanel. In case there is no ․htaccess file, check if Show Hidden Files is enabled in the File Manager.

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

Important: Make sure that the line RewriteEngine On is not repeated twice. In case the line already exists, simply copy the rest of the code without it.

Note: The ․htaccess file needs to be located in your public_html directory. If your website is addon domain, then the ․htaccess should be placed in the corresponding folder.