Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

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

There's actually 2 questions.

One is, how do I make RewriteCond+RewriteRule change domain2/folder1 to domain1/folder1

Actually what I want is any domain that tries to access folder1 that is not domain1 gets switched to domain1. So for example -> as well as ->

This is what I tried

RewriteCond %{HTTP_HOST}     !^domain1\.com$ [NC]
RewriteCond %{REQUEST_URI}   ^/folder1/
RewriteRule ^/folder1/(.*)$$1 [L,R=permanent]

But that doesn't work. Next I tried some a simpler rule to see if I could narrow down the issue.

RewriteCond ${HTTP_HOST}  domain2\.com [NC]
RewriteRule ^(.*)$ [L]

I though that would make ANY request to go to so I tried but I get not If I go to I get google. Why don't I get there if I go to

What am I not understanding about mod_rewrite?

share|improve this question

Never mind. The above rules work. The issue was I actually had a "folder1" and inside was another .htaccess file. DOH!

share|improve this answer

Your Answer


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