How to Force SSL Using .htaccess Print

  • 39

To force all the pages to load through SSL please add the below code in the .htaccess file located in root or home directory.

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

If you want to do it for a specific folder/directory then use the below code instead the above:

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

Please replace folder/directory name, www.yourdomain.com with the folder/directory name you want to force SSL on and your domain name respectively.


Was this answer helpful?

« Back