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

I have multiple domains pointing to the same site.

Example:

I have www.admin-domain.com pointing to /var/www

I have www.test.com pointing to /var/www/test directory and this is OK.

Example:

www.admin-domain.com/test shows the same content as www.test.com

Using a .htaccess file how do I block www.admin-domain.com/test ?

share|improve this question

Drop a .htaccess file into /var/www with belows content:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.admin-domain\.com [NC]
RewriteCond %{REQUEST_URI} ^/test/.*
RewriteRule ^(.*)$ - [F,L]

but your example seems to contradict to what you said before.

share|improve this answer
    
I tried as you said but I still have access to <code>www.admin-domain.com/test</code> – stevs986 Nov 3 '11 at 16:07

Create a .htaccess in the "test" directory with the following contents:

RewriteEngine On
RewriteCond %{HTTP_HOST} !www.test.com$
RewriteRule (.*) - [F]

If the vhost accessing the file isn't www.test.com then the server will return a 403 Forbidden message.

share|improve this answer

Your Answer

 
discard

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.