Forcing HTTPS Redirects via .htaccess

If you have an SSL certificate installed as shown in the "SSL/TLS Status" tool in cPanel but your domain isn't loading securely by default, you can edit your .htaccess file to fix it.

 

  1. When logged in to cPanel, click the "File Manager" icon.
  2. Open the web root directory for the domain in question - if it is your primary domain name, the web root will be public_html.
  3. Click "Settings" in the top right corner of the page.
  4. Check the box next to "Show Hidden Files (dotfiles)".
  5. Click "Save".
  6. Find the file named ".htaccess" in the list. If there is no .htaccess file, click the "+File" icon at the top of the page to create a file and name it .htaccess.
  7. Right click the .htaccess file and select "Edit" from the list.
  8. Paste the following code into the bottom of the .htaccess file after any other code that is already present:

 

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
RewriteCond %{REQUEST_URI} !^/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]

 

Click the blue "Save Changes" button at the top of the page to save the edit.

  • 8 Users Found This Useful
Was this answer helpful?

Related Articles

Is it a problem if I'm not in the US?

Not at all! In fact, we already have customers in countries all over the world.

I uploaded my page but it's not working!

Make sure that you are uploading to the public_html or www folder.  Only the files placed...

What is an error 404 page?

Error 404 indicates that you are requesting a file or a directory that does not exist on the...

Can I run scripts like Wordpress, Joomla, or phpBB on my site?

Absolutely! We make it extremely easy to install over 250 different scripts via the Softaculous...

Can I upgrade my plan or features later?

Upgrades/Addons are available to purchase at any time through your Client Area dashboard. Once...