ANGRYKOREAMAN
ANGRYKOREAMAN

Reputation: 85

.htaccess rewrite all subdomains to root

This may be asked somewhere else but can't really find an answer to this one.

I want to redirect all the subdomains (*.domain.com) to the root (i.e. domain.com) using an htaccess. So in short:

test.domain.com -> domain.com
asdasdasd.domain.com -> domain.com
etc.

Thanks!

Upvotes: 0

Views: 2117

Answers (1)

landi
landi

Reputation: 343

Try the following, it should work

RewriteCond %{HTTP_HOST} ([^.]+)\.domain.com [NC]
RewriteRule ^(.*) http://domain.com/

Upvotes: 3

Related Questions