Portal Home > Knowledgebase > SSL Certificates > Add or Force SSL Certificates

Add or Force SSL Certificates

After adding an SSL certificate to force all web traffic and use HTTPS, insert the code below into the .htaccess file. 

Important: with any existing code that is in your .htacess, you will need to add this above any currect rules with a similar starting prefix.

 Force www only

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

Be sure to replace www.example.com with your domain name.

 Force www and naked domain

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

be sure sure to replace example\.com and www.example.com with your domain name.

 Force folder only

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

Be sure you change the folder reference to the folder name.


 

Powered by WHMCompleteSolution