How to Force HTTPS using .htaccess (cPanel)

Sitebee

Technical SEO
Staff member
  • Go to File Manager in cPanel and open .htaccess inside the public_html folder.
  • To force all web traffic to use HTTPS, insert the following lines of code in the .htaccess file in your website’s public_html folder.

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

NOTE* You can also add .htaccess files in sub-domain root folder.