Knowledgebase
Portal Home > Knowledgebase > SSL Certificates > Add or Force SSL Certificates
Add or Force SSL Certificates
After adding an SSL certificate to force traffic to use HTTPS, add this code to the .htaccess file.
Important: Add this above any current rule.
To force www only
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.yourwebsite.com/$1 [R,L]
To force www and naked domain
RewriteEngine On
RewriteCond %{HTTP_HOST} ^yourwebsite\.com [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.yourwebite.com/$1 [R,L]
To force folder only
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} folder
RewriteRule ^(.*)$ https://www.yourwebsite.com/directory/$1 [R,L]
Be sure you change the directory reference to the folder name.
Be sure to replace www.yourwebsite.com with your domain name.