Forcing HTTPS Redirects via .htaccess Print

  • 10

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.


Was this answer helpful?

« Back