Webmasters Stack Exchange is a question and answer site for pro webmasters. 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

Let's say I have the sites siteA.com and siteB.com. They are hosted such that siteB.com actually points to siteA.com/siteB.

How can I block someone from visiting siteA.com/siteB using mod_rewrite?

So far I've tried this to no avail (in root of siteA.com):

RedirectMatch 301 ^/siteB/$ http://someothersite.com/
share|improve this question

migrated from serverfault.com Mar 6 '11 at 2:26

This question came from our site for system and network administrators.

up vote 1 down vote accepted

Try something like

# you may need to drop the leading slash if you're doing this in .htaccess   
RewriteCond %{HTTP_HOST} !^siteB\.com$
RewriteRule ^/siteB  http://siteB.com/ [R=301]
share|improve this answer
Thank you very much! – Chris Laplante Mar 7 '11 at 22:03

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.