I’ve been searching quite a bit now but cannot find the answer to this. I’m trying to have the domain (or any other pointing to it) to redirect to the version without ‘www’ (if it is present), but to leave sub domains so it works the following way:
http://www.domain.com -> http://domain.com
http://www.otherpointing.com -> http://domain.com
http://otherpointing.com -> http://domain.com
http://m.domain.com -> http://m.domain.com
So far I’ve got the following, which doesn’t seem to respect sub-domains:
RewriteCond %{HTTP_HOST} !^domain\.com$ [NC]
RewriteRule ^(.*)$ http://domain.com/$1 [L,R=301]
Any idea?
or optionally, to keep subdomains from other domains: