Exception for allow/deny directive possible? [SOLVED]

Need help installing PHP, configuring a script, or configuring a server? Then come on in and post your questions! We'll try to help the best we can!

Moderator: General Moderators

Post Reply
tomfra
Forum Contributor
Posts: 126
Joined: Wed Jun 23, 2004 12:56 pm
Location: Prague, Czech Republic

Exception for allow/deny directive possible? [SOLVED]

Post by tomfra »

Let's say I have a .htaccess file similar to this:

Code: Select all

Order Deny,Allow
allow from 123.132.123.132
allow from 123.132.123.133
Deny from all
This will effectively restrict access to the website (or a directory and subdirs) to only the above listed IPs. Request for any file coming from IP not listed there will get a 403 Permission Denied Error.

But with this settings in place, I'd like to make an exception for one file. In other words, one particular file, let's say "exception.html" should be available to any request from any IP unlike the other files.

Is this possible?

Thanks!

Tomas
Last edited by tomfra on Tue Feb 08, 2005 4:41 pm, edited 1 time in total.
User avatar
Buddha443556
Forum Regular
Posts: 873
Joined: Fri Mar 19, 2004 1:51 pm

Post by Buddha443556 »

Might try a file directive:

Code: Select all

<Files ~ "exception.html">
Order allow,deny
Allow from all
</Files>
Have no idea if this will actually work ... never tried it. I'm also thinking Apache so your mileage may vary.
tomfra
Forum Contributor
Posts: 126
Joined: Wed Jun 23, 2004 12:56 pm
Location: Prague, Czech Republic

Post by tomfra »

Yes, it did the trick!

Thanks a lot!

By the way, you have a typo in your sig file - "Kenned" instead of "Kennedy".

Tomas
tomfra
Forum Contributor
Posts: 126
Joined: Wed Jun 23, 2004 12:56 pm
Location: Prague, Czech Republic

Post by tomfra »

One more question if you don't mind ;)

Is it possible to use one Files directive section & list multiple different filenames? I am having difficulty with finding this info in the Apache manual...

Tomas
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

http://httpd.apache.org/docs/mod/core.html#files

talks about it right there. FileMatch may be a better option though (look before the <Files> directive.
User avatar
Buddha443556
Forum Regular
Posts: 873
Joined: Fri Mar 19, 2004 1:51 pm

Post by Buddha443556 »

Thanks Tomfra, I fixed my sig. :oops:

Can use regular expression with <files> too. Actually that the one I used above with the ~ character.
Post Reply