How do I redirect all visitors to HTTPS? Print

  • hosting, ssl, https, redirect
  • 0

To automatically redirect all visitors to the secure (HTTPS) version of your website you can add the following code to an .htaccess file in your public_html folder:

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

If an .htaccess file does not exist in your public_html folder, create this file and place the above code in it.

If you have an existing .htaccess file do not duplicate the "RewriteEngine On" line if one already exists in the file. Simply place the RewriteCond and RewriteRule lines immediately below your existing "RewriteEngine On" line.


Was this answer helpful?

« Back