RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^(contact|login)/$ https://%{SERVER_NAME}/$1/ [R,L]
RewriteCond %{SERVER_PORT} ^443$
RewriteCond %{REQUEST_URI} !^(contact|login)/$
RewriteRule ^([a-z]+)/$ http://%{SERVER_NAME}/$1/ [R,L]
The above is the code I am using to make sure the pages /login/ and /contact/ are SSL encrypted. I am not hardcoding URLs in my site so all relative urls reason redirecting a user, when they access
http://www.example.com/login/ it will redirect them the https version. But once they are on that page ALL the links in the page get the https scheme. So want it when they are in https and click on a link that is NOT /contact/ or /login/ it will break them out of https by redirecting them to the http version. Right now it is not working and is causing infinite redirection. Anyone know how to do this?