Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

2 Answers 2

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 /var/www/test directory with the following contents

RewriteEngine On
RewriteConnd %{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.