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

My hosting provider requires that my primary domain (let's call it example.com) points to my public_html root. I also own several other domains (let's call them exampleA.com and exampleB.com) that are hosted in sub-directories such that they can be accessed via http://example.com/exampleA/ and http://example.com/exampleB/

I would like to restrict people from accessing these secondary sites in this way. Ideally, there will be no indication that the secondary sites are in any way related to the primary domain. How do I do this? Modify the .htaccess file?

share|improve this question

This should do it

RewriteEngine on
RewriteCond %{HTTP_HOST} ^example\.com$ [NC]
RewriteRule ^exampleB/ - [R=404,L]

(Adapted from this answer but I think mine is right whereas the first example in that one is wrong as it uses the wrong domain in RewriteCond. That should be enough, but you could try the other things in that question if it doesn't work.)

share|improve this answer
+1 But see a possible improvement on this here: webmasters.stackexchange.com/a/24363/3738 - this I believe stops unwanted paths appearing in the results in the first place. – therobyouknow Jan 9 '12 at 17:01
Thanks, that's a useful link. – paulmorriss Jan 9 '12 at 17:15

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.