Get your server issues fixed by our experts for a price starting at just 25 USD/Hour. Click here to register and open a ticket with us now!

Author Topic: setting https using .htaccess file  (Read 1159 times)

0 Members and 1 Guest are viewing this topic.

aravindm

  • Guest
setting https using .htaccess file
« on: February 17, 2018, 03:05:38 pm »
Append the following lines in your .htacess file.
Code: [Select]
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]

To force a specific domain to use HTTPS, use the following lines of code in the .htaccess file in your website's root folder:
Code: [Select]
RewriteEngine On
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]

If you want to force SSL on a specific folder you can insert the code below into a .htaccess file placed in that specific folder:
Code: [Select]
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} folder
RewriteRule ^(.*)$ https://www.example.com/folder/$1 [R,L]

Note:
Dont't forget to replace www.example.com with your actual domain name  ;)