.htaccesshttp-redirecthttpsresin

How to enforce https from htaccess?


I have to enforce https everytime when the sign-in site-node is loading. For example http://www.mysite.com/sign-in should always be enforced to https.

I tried multiple versions but none of them worked. It's the first time when I am using .htaccess

here is what i tried:

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} sign-in
RewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI}/$1 [R,L]

Solution

  • I solved it with :

    RewriteCond %{HTTP:X-Forwarded-Proto} !https
    RewriteCond %{REQUEST_URI} /sign-in
    RewriteRule !(.*)lbping(.*) https://%{SERVER_NAME}%{REQUEST_URI} [L,R]