Force https:// on your website

How it works:

If you have SSL installed and your browser is giving you security warnings, you may have to force prefix https:// to be used

  • You need an SSL certificate installed on your website in order to see the secure green lock next to your URL in the browser
  • Free SSL is enabled when you purchase Free SSL (only $1) installation on bpmicloud.com. 
  • Free SSL is recommended for websites which are not processing payments.
  • All e-commerce sites should purchase an SSL Certificate instead (dedicated IP address required).
  • SSL only works with an https:// prefix in your browser

To force SSL prefix using .htaccess file:

If you have existing code in your .htaccess, add this above where there are already rules with a similar starting prefix.

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

If this doesn’t work, try removing the first two lines.

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

Make sure to replace example.com with the domain name you’re trying force to https. Additionally, you need to replace www.example.com with your actual domain name.

Redirect Specified Folder

If you want to force SSL on a specific folder, insert the code below into a .htaccess file placed in that specific folder:

RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$ RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$ RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteCond %{REQUEST_URI} folder RewriteRule ^(.*)$ https://www.example.com/folder/$1 [R=301,L]

Make sure you change the folder reference to the actual folder name. Then be sure to replace www.example.com/folder with your actual domain name and folder you want to force the SSL on.

If you need further assistance please feel free to leave a question below.

reference: inmotionhosting.com December 2019

 
  • 1 Users Found This Useful
Was this answer helpful?

Related Articles

How Do I Turn On Auto SSL?

How do I turn on AutoSSL? (Free SSL) 1)      Sign in to your account.       2)      Click...