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

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

1 Answer 1

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.