• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 220
  • Last Modified:

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

0
jabberwok_e
Asked:
jabberwok_e
  • 2
  • 2
1 Solution
 
caterham_wwwCommented:
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?

0
 
jabberwok_eAuthor Commented:
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
0
 
caterham_wwwCommented:
> Should the <directory> tags be in the httpd.conf file

httpd.conf

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

May be the AllowOverride directives are set in a way that overriding "FileInfo" is not permitted in .htaccess files? Anyway, if you have access to the httpd.conf, you shouldn't use .htaccess files (performance reasons).
0
 
jabberwok_eAuthor Commented:
Fantastic! it works exactly as needed!

Thank you very much.

Bill
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now