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

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

So I'm trying to write a mod_rewrite rule that will send everything on my main domain to a subdomain.

For example, redirect


Here's what I have so far:

RewriteEngine On
RewriteCond ^http://www\\/ [NC]
RewriteRule ^(.*)$$1 [R=301,L]

But it doesn't seem to working. Any tips?

share|improve this question
@Shane Madden - don't think it's a dupe myself. That linked q is very helpful, but since it doesn't cover this specific question I think it is useful in its own right. – Gavin C May 23 '11 at 22:24
@Gavin Fair point. That question could use a wider breadth of examples, it's a little heavy on referrer examples at the moment. – Shane Madden May 24 '11 at 0:46

I think you're missing something in your RewriteCond line. Try this:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^http://www\\/ [NC]
RewriteRule ^(.*)$$1 [R=301,L]

So add the %{HTTP_HOST} into your RewriteCond rule... Note that I haven't tested this, so please post the results...

share|improve this answer

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.