How to force SSL with .htaccess

You can force an HTTPS connection on your website by adding these rules in your website's .htaccess file:

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

The .htaccess file needs to be located inside the site's document root folder. If your website is in a sub folder, then the .htaccess should be placed in the corresponding sub folder.
You can create or edit the .htaccess file either via FTP, or using with the File Manager available in cPanel.

Was this answer helpful?

 Print this Article

Also Read

How to specify a custom php.ini for a web site

Linux: Creating a new php.ini file If you do not have a php.ini file in your public_html folder...

Google Email MX Setup in cPanel

Login to your cPanel and open Zone Editor Click on Manage Remove all existing MX records Add...

How fast are accounts set up?

QSS Hosting strives for a setup time of no more than 60 minutes per shared hosting order. If an...

Unblock IP address from server firewall

All our shared Linux hosting servers are protected by firewall. While the purpose of a firewall...

Domain has exceeded the max defers and failures per hour

What is this error?If you are receiving an error similar to "Domain example.com has exceeded the...