How do i prevent use of a subdirectory according to HTTP_HOST.

I've 2 parked domain names pointing to 1 directory. Both of them offer exactly the same website.

However If only each to possess a seperate wordpress blog. To get this done I am setting up them in various sites.

Unfortunately the sites are available across domain names. For example

I Truly do not want individuals to have the ability to access across domain names. Wordpress will break and that i can get duplicate content issues in the search engines.

What's the EXACT code I have to put in my htaccess file for everyone up a 404 error should anybody attempt to access OR

I figured maybe using HTTP_HOST coupled with mod_rewrite in some way?

I am a large newb if this involves htaccess, therefore the more explicit you may be the greater.


Try adding the next for your htaccess file within the root directory of the domain

RewriteEngine on
RewriteBase /

#if its domain1
RewriteCond %{HTTP_HOST} domain1\.com$ [NC]
#and the request is for domain2 blog
RewriteCond %{REQUEST_URI} ^/domain2-blog/ [NC]
#send a 403 forbidden
RewriteRule . - [F,L]

#if its domain2
RewriteCond %{HTTP_HOST} domain2\.com$ [NC]
#and the request is for domain1 blog
RewriteCond %{REQUEST_URI} ^/domain1-blog/ [NC]
#send a 403 forbidden
RewriteRule . - [F,L]