0

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]
andrew
  • 2,797
  • 3
  • 18
  • 16

2 Answers2

0

You shouldn't use %{REQUEST_URI} and $1 together in rewritten URL.

You can try this code:

RewriteCond %{HTTPS} off
RewriteRule sign-in https://%{HTTP_HOST}%{REQUEST_URI} [L,NC,R=301]
anubhava
  • 761,203
  • 64
  • 569
  • 643
  • Tried that also, and it's still not working. Could be because there are some request params after sign-in? – andrew Oct 25 '13 at 12:53
  • No params don't matter. Can you directly visit `https://site.com/sign-in` in the browser? – anubhava Oct 25 '13 at 12:55
  • Then make sure this .htaccess and mod_rewrite are enabled and this rule is first your after `RewriteEngine On` – anubhava Oct 25 '13 at 12:58
0

I solved it with :

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