Force website visitors to use SSL (https) using htaccess

If you get the message in web browser that your website is "not secure" (not showing the lock icon) then try the instructions below.

UPDATE: This is now a setting in CPanel at Domains > Domains (enable "Force HTTPS Redirect")
This will redirect website users from non secure HTTP to secure HTTPS.
CPanel provides free SSL, so it is wise to ensure your visitors use it by enabling "Force HTTPS Redirect".
If this does not work try the manual htaccess method below.

-----------------------------------------------------------------------------------------------------------------------------------------------------------

To force all connections to use SSL create a blank text file (in the root folder) named .htaccess (with period at beginning) using the CPanel File Manager.
You may find the .htaccess file already exists in which case you can just add to it.
In this file paste the text below: (replace www.example.com with your domain)

RewriteEngine On 
RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]

Port 80 is the port used for all web traffic for web pages.
Files starting with a period are "invisible" files.
You may need to set the CPanel File Manager to show invisible files in the Settings button (top right).

Other Examples:

The code can be modified to pertain to a specific domain only:

RewriteEngine On 
RewriteCond %{HTTP_HOST} ^example\.com [NC]
RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]

Replace www.example.com with your info.

... or a specific folder only:

RewriteEngine On 
RewriteCond %{SERVER_PORT} 80 
RewriteCond %{REQUEST_URI} foldername
RewriteRule ^(.*)$ https://www.example.com/foldername/$1 [R,L]


Replace foldername and www.example.com/foldername with your info.


  • SSL, htaccess
  • 1 Users Found This Useful
Was this answer helpful?

Related Articles

Addon Domains, Sub Domains, Parked Domains

UPDATE: Previous versions of CPanel had different sections for adding domains, sub domains, and...

Are your IP addresses Canadian based?

By default IP Addresses and servers are based in Canada, but can be based in the US upon...

Error: (XID q8x5hn) Could not determine the nameserver IP addresses

"Error: (XID q8x5hn) Could not determine the nameserver IP addresses for this domain. Please make...

Connect Domain to Third Party Hosting for Website while using NewMediaCanada.com for E-Mail

Have your website at another host such as WordPress.com or Squarespace, but keep email on our...

Connect Domain to Wix.com

There are two options for connecting your domain to wix.com Pointing vs. Name Servers Domain...