Forum Moderators: phranque
# if https is OFF and request is for page which should be secure,
# redirect to https
RewriteCond %{HTTPS} off
RewriteCond %{THE_REQUEST} ^[A-Z]+\ /(contact|order)\.php
RewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R=301]
# if https is ON and request is NOT for page which should be secure,
# redirect to http
RewriteCond %{HTTPS} on
RewriteCond %{THE_REQUEST} !^[A-Z]+\ /(contact|order)\.php
RewriteRule ^(.*)$ http://%{SERVER_NAME}%{REQUEST_URI} [L,R=301]
[edited by: jdMorgan at 3:14 pm (utc) on Apr 21, 2010]
[edit reason] De-linked URLs in code. [/edit]
# if https is OFF and request is for page which should be secure,
# redirect to https
RewriteCond %{HTTPS} =off [NC]
RewriteRule ^(contact|order)\.php$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
#
# if https is ON and request is for a page, but NOT for page which
# should be secure, redirect to http
RewriteCond %{HTTPS} !^(off)?$ [NC]
RewriteCond $1 !^(contact|order)\.php$
RewriteRule \.(php[0-9]*|html?)$ http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]