You can check the status of HTTPS by using RewriteCond {%HTTPS} on (or !on)
You can check for www. on the host using RewriteCond {%HTTP_HOST} ^www\.(.*)$ (or !^www\.(.*)$). The pattern matched is in %n, and RewriteRule backreferences are $n.
You can rewrite URLs using RewriteRule ^(.*)$ http://www.%1/$1 [R=301,L]. By switching http for https and removing the www., you can change this to fit the HTTPS rule.
Grab the Apache Mod_Rewrite Documentation. Also http://whathaveyoutried.com.
You can check the status of
HTTPS
by usingRewriteCond {%HTTPS} on
(or!on
)You can check for
www.
on the host usingRewriteCond {%HTTP_HOST} ^www\.(.*)$
(or!^www\.(.*)$
). The pattern matched is in%n
, andRewriteRule
backreferences are$n
.You can rewrite URLs using
RewriteRule ^(.*)$ http://www.%1/$1 [R=301,L]
. By switchinghttp
forhttps
and removing thewww.
, you can change this to fit theHTTPS
rule.The final code:
And I'll say it again, http://whathaveyoutried.com