Htaccess allow deny probs

software development

#1

Hi,

I’m having trouble with access control using .htaccess files, I’m trying to use the following code:

order deny, allow
deny from all
allow from 123.123.12/121
allow from 121.23.112.1/123
allow from 21.123.11.1/99

(IP Numbers changed)

this causes error 500 when trying to access the protected directory. Other .htaccess files I have written work correctly, but I can’t get the allow\deny code working. What am I missing?

Any help will be greatly apreciated,
-Rich.


#2

Cheers for the reply.

I read though both of the linked pages you provided and tried making a few changes, but still no luck.

The files are created with notepad (no word wrap) and uploaded as a txt file in ascii mode before being renamed. The chmod setting is 644. I even tried it with just my own IP address allowed and the with just the first two lines (order, and deny all) throws up error 500 every time. I’ve had no problems with other commands (custom error docs, Dir indexing off, redirect and addtype).

-Rich.


#3

I added limit tags(I’m sure I read that they’re not required) and all seems to be well. Thanks for your help.

-Rich.


#4

allow from 123.123.12/121 allow from 121.23.112.1/123 allow from 21.123.11.1/99The numbers after the slash must be a netmask. The netmask can be the number of bits or a quad:

bits = 192.168.0.1/16 = net is 192.168..
quad = 192.168.0.2/255.255.0.0 = net is 192.168..

Also, if you get 500 errors, there will be a log entry in your Apache error.log file that should explain why the error occured.

:cool: Perl / MySQL / HTML+CSS


#5

!!! why didn’t I think of the error log? also didn’t realise how the ip ranging worked. Cheers :slight_smile:

-Rich.