Forum Moderators: phranque

Message Too Old, No Replies

htaccess allow deny question

Sorry if its been asked before..

         

LoneGunman

9:21 pm on Jan 23, 2004 (gmt 0)

10+ Year Member



Using htaccess I want to block whole series of IPs and allow everyone else in, but what if I want to allow just one Ip or a small subset of one of the ranges in and keep the others out. Something like this....

<Limit GET>
order allow,deny
allow from all
allow from 194.117.104
deny from 194
deny from 195
deny from 196
deny from 197
</Limit>

Would this allow the 194.117.104 set in along with everyone else except the deny from list? If not what would be the scheme to use?

Thanks

jdMorgan

9:58 am on Jan 24, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Try it this way:

<Files *>
Order Deny, Allow
Deny from 194
Allow from 194.117.104
Deny from 195
Deny from 196
Deny from 197
</Files>

The best course of action when undertaking to use the Order directive is to open the documentation to mod_access [httpd.apache.org] and read it again carefully - even after several years of using it... This prevents *very* nasty surprises! :)

If you use <Limit GET> as a container, then those access rules will apply only to the HTTP GET method, and your "Denied" IP address range will be able to POST, DELETE, or whatever else they may want to do, other than GET... :(

Jim

LoneGunman

2:28 pm on Jan 24, 2004 (gmt 0)

10+ Year Member



Thanks for the reply. With the above example anyone from any other IP would be able to access as well?
If so this is just what I was looking for.

coopster

2:50 pm on Jan 24, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Yes, because of the
Order
, the
Deny
directives are evaluated before the
Allow
directives. Access is allowed by default. Any client which does not match a
Deny
directive or does match an
Allow
directive will be allowed access to the server.

The link provided by jdMorgan is good reading, your answer was listed there,
he said with a gentle, friendly, caring nudge :)

LoneGunman

3:03 pm on Jan 24, 2004 (gmt 0)

10+ Year Member



Thanks, just what I needed.

Gentle caring nudges don't work, I need a kick in the rear. Checking the link now.

[edited by: jdMorgan at 11:09 pm (utc) on Jan. 24, 2004]
[edit reason] typo [/edit]