I’m forcing a URL change if the user has accessed the site via http://mysite or http://www.mysite
However currently I only check that the site does not equal the main sub-domain which is http://store
I also have another sub-domain but this is being overwritten as well, so I need to change the way my current code works which is:
RewriteEngine On
RewriteCond %{HTTP_HOST} !^store\.mysite\.com [NC]
RewriteRule (.*) http://store.mysite.com/$1 [R=301,L]
I would prefer to have it check if the url is either of these:
http://mysite.com
http://www.mysite.com
…and then apply the rewrite rule, how do I change my Rewrite condition to do this?
Try this one — works just fine here:
QSAflag here since it is 301 redirect (depends on your actual URLs) —[R=301,QSA,L].Other approaches:
1) Separate condition for each domain name (need to specify that
ORlogic needs to be used instead of defaultAND):2) The same as above .. but using plain text comparison instead of regex: