Forum Moderators: phranque
RewriteEngine On
# first, all pages w/o www get www rewrite under all circumstances
RewriteCond %{HTTP_HOST} ^vintage-adventures\.com$ [NC]
RewriteRule ^(.*)$ [%{HTTP_HOST}%{REQUEST_URI}...] [R=301]
# then, certain pages that already have www, but that
# also need to be secure, get the https rewrite
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^www\.vintage-adventures\.com$ [NC]
RewriteCond %{QUERY_STRING} login|logoff|account|checkout|contact|address
RewriteRule ^(.*)$ [%{HTTP_HOST}%{REQUEST_URI}...] [R=301]
# then, certain secure pages currently w/ or w/o https, but that
# are also missing www, get www rewrite, and https rewrite if missing
RewriteCond %{HTTP_HOST} ^vintage-adventures\.com$ [NC]
RewriteCond %{QUERY_STRING} login|logoff|account|checkout|contact|address
RewriteRule ^(.*)$ [%{HTTP_HOST}%{REQUEST_URI}...] [R=301,L]
RewriteCond {%HTTP_HOST} !^(www\.example\.com)?$ which means "not EXACTLY 'www.example.com'", as this will also redirect requests with unwanted trailing port numbers too. !(log(in|off)|account|checkout|contact|address|time_out) # Redirect specific http OR non-www requests to https AND www.
# Redirect all other https OR non-www requests to http AND www.