Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have a domain (lets call it and I want the default hostname to be So, would be redirected to and would correspond to the main httpdocs folder (I don't want my entire site to be in subdomains/foo/httpdocs, that's just plain ugly and redundant).

I've set as an alias to in Plesk and that works fine. Then, to redirect to I used an .htaccess with the following:

RewriteCond %{HTTP_HOST} ^foo\.bar\.com
RewriteRule ^(.*)$$1 [R=301,L]

However, as you have probably figured by now, this results in a redirect loop.

Any ideas?

share|improve this question

migrated from Nov 4 '11 at 8:00

This question came from our site for professional and enthusiast programmers.

To the ones voting to close this as off-topic: Maybe you should take a look at the THOUSANDS of similar threads in stackoverflow. I did, before I opened this to make sure it's not off topic. –  Lea Verou Nov 3 '11 at 2:24
We are slowly cleaning them up. Don't worry. –  mauris Nov 3 '11 at 10:33

1 Answer 1

up vote 1 down vote accepted

You left out a ! in your RewriteCond to indicate that you DON'T want the host to be

RewriteCond %{HTTP_HOST} !^foo\.bar\.com
RewriteRule ^(.*)$$1 [R=301,L]
share|improve this answer
Whoops, I can't believe I didn't see that!! EPIC FAIL. Thanks!! –  Lea Verou Nov 3 '11 at 3:20

Your Answer


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