Apache SSL for login and NON-SSL for everything else (.htacces)
- by The Devil
Hey
I've almost figured it out on my own but there's something I'm missing.
I want to set a couple of directories and files to require SSL and everything else that's not related to those files and dirs to point back to http.
So far I have this:
RewriteEngine on
RewriteBase /
# Force ssl for login & admin
RewriteCond %{HTTPS} !on
RewriteRule ^/?(admin(.*)|login\.php)$ https://%{SERVER_NAME}/$1 [R,NC,L]
# Force non-ssl for others
RewriteCond %{HTTPS} on
RewriteRule ^/?(admin(.*)|login\.php)$ http://%{SERVER_NAME}/$1 [R,NC,L]
I'm sure I'm doing something wrong but I just can't figure it out....
The first condition works perfect - whenever I access login.php or /admin/ it points to https. But the second one doesn't...
Where have I mistaken ?
Thanks in advance!