views:

17

answers:

1

The following forces non-www domains and sends https requests to http and is working fine for example.com. How can I use a wildcard for the domain?

RewriteCond %{HTTP_HOST} !^example\.com$
RewriteCond %{SERVER_PORT}s ^(443(s)|[0-9]+s)$ 
RewriteRule (.*) http%2://example.com/$1 [R=301,L] 

I have two domains, example.com and example2.com. Both use the same code base and point to the same folder. If a visitor comes to the site via example2.com, the URL needs to remain example2.com and not shift to example.com.

A: 

Try this rule:

RewriteCond %{HTTP_HOST} .+\.([^.]+\.[^.]+)$
RewriteCond %{HTTPS}s%1 ^on(s)(.+)|
RewriteRule ^ http%1://%2%{REQUEST_URI} [R=301,L]
Gumbo