Jargonaut
Jargonaut

Reputation: 75

htaccess 301 redirect everything except subdomain?

I wish to redirect an entire domain except for 1 subdomain to another site.

I'm trying to get:

http://domain.com

http://www.domain.com

to redirect to another website/domain.

I want subdomain.domain.com to remain unaffected.

So far I have only managed to get either the www or the non www versions to redirect but not both at the same time.

Any assistance would be much apreciated.

Upvotes: 2

Views: 3026

Answers (1)

scibuff
scibuff

Reputation: 13755

RewriteEngine On
RewriteCond %{HTTP_HOST} !^subdomain\.domain\.com
RewriteRule ^(.*)$ http://www.another-domain/$1 [R=301,L]

Upvotes: 6

Related Questions