Reputation: 117
We need to force HTTPS only for one specific page and one directory, i.e. /login.php and anything in the /forum directory. All other pages on the site should be forced into HTTP (even if manually requested as HTTPS).
I'm hitting roadblocks getting this to work via .htaccess... can anyone help? Thanks so much!
Upvotes: 1
Views: 69
Reputation: 41219
You can use the following rewriteRules :
RewriteEngine on
#force https for /login.php and /forum
RewriteCond %{HTTPS} off
RewriteRule ^(login\.php|forum/.*)$ https://%{HTTP_HOST}/$1 [NE,L,R]
#redirect everything else to http if requested as https
RewriteCond %{HTTPS} on
RewriteRule ^((?!login\.php|forum/.*).*)$ http://%{HTTP_HOST}/$1 [NE,L,R]
Upvotes: 2