Sign up ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

I'm looking for some help in accomplishing redirects based on the subdomain. For example if some tries to access:

it will redirect to:


and if they go to:

it will redirect to:


I only need the root redirected, so if they go to:

it will not redirect.

I know the basics of creating htaccess files, I just can't seem to get it right for some reason to accomplish this. Any help is highly appreciated.


P.S. I should mention that all these subdomains point to the same document root.

share|improve this question

1 Answer 1

up vote 0 down vote accepted

With mod_rewrite active try

RewriteEngine on
RewriteCond %{HTTP_HOST} !^$
RewriteRule ^$ /file.php?test=something [L,R=301]
RewriteCond %{HTTP_HOST} !^$
RewriteRule ^$ /file.php?test=somethingelse [L,R=301]
share|improve this answer
Thank you ... turns out I had it correct all along, but my browser cache was caching the old incorrect results so I didn't realize it was fixed. – Harry Muscle Apr 1 '13 at 0:07

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.