After installing an SSL certificate in your website, it is available over HTTP and HTTPS.

However, it’s better to use only the https access because it encrypts and secures your website’s data.

Here are many different options to force the https loading in your website using the .htaccess file.

You have to copy the following lines in the .htaccess named file in your public_html, if the file doesn't exist in your public_html, create it.

 

Force Https on All traffic:

RewriteEngine On 
RewriteCond %{HTTPS} off 
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

Force Https on a Specific Domain:

RewriteEngine On 
RewriteCond %{HTTP_HOST} ^mydomain1.net [NC] 
RewriteCond %{HTTPS} off 
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

Force Https on a Specific Folder:

RewriteEngine On 
RewriteCond %{HTTPS} off 
RewriteRule ^(folder1|folder2|folder3) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

Was this answer helpful? 0 Users Found This Useful (0 Votes)