Link to home
Start Free TrialLog in
Avatar of jabberwok_e
jabberwok_e

asked on

htaccess to deny access by requested URL

I have a virtual host set up on my apache web server. This redirects to a folder as such: /var/www/html/site2 this is <ourcustomer.com>

The default Virtual host points to /var/www/html/ as the root. This is <oursite.com>

I want to stop anyone using <oursite.com>  from accessing the site2 directory

This is mainly just to make sure that our other customers don't stumble across our hosted customer's site tied to our domain name.

I tried many variations of the following code with no luck, I also tried {REQUEST_URI} with no luck.

I could recreate the default virtual host into another directory, but because of many of the internal programs and scripts, this would cause a lot of extra work.

Thanks in advance for your time.
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.oursite\.com$ [NC]
RewriteRule (.*) - [F,L]

Open in new window

Avatar of caterham_www
caterham_www
Flag of Germany image

Did you place the code into a

<Directory /var/www/html/site2>
Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www\.oursite\.com$ [NC]
RewriteRule ^ - [F,L]
</Directory>

section?

Avatar of jabberwok_e
jabberwok_e

ASKER

No,

I just have it in a .htaccess file in the /var/www/html/site2 directory.

Should the <directory> tags be in the httpd.conf file or .htaccess file in the root directory?

Bill
ASKER CERTIFIED SOLUTION
Avatar of caterham_www
caterham_www
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Fantastic! it works exactly as needed!

Thank you very much.

Bill