Forum Moderators: phranque

Message Too Old, No Replies

.htaccess not working

deny from

         

robertito62

12:35 am on May 20, 2004 (gmt 0)

10+ Year Member



I am trying to limit access to one site using .htaccess.

This is what is written:

<Limit GET PUT POST>
order deny,allow
deny from xx.xx.****.x
</Limit>

For some reason, the ip in question can still access the site. Am i missing some line in the file?
Thanks.

jdMorgan

12:45 am on May 20, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Even if that worked, it would only block access for those HTTP methods, leaving the site open for DELETE and several other interesting requests.

Try LimitExcept, or even better, a Files container:

<Files *>
Order Deny,Allow
Deny from 192.168.0.1
</Files>

Jim

robertito62

1:23 am on May 20, 2004 (gmt 0)

10+ Year Member



Thank you Jim.
Files container must work like this I guess?

<Files /somedirectory/somefile.html>
Order Deny,Allow
Deny from 192.168.0.1
</Files>

and will this limit access to all html/htm files?

<Files ~"^\ht">
Order Deny,Allow
Deny from 192.168.0.1
</Files>

jdMorgan

1:30 am on May 20, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You're missing a period in the following code, and it should not be start-anchored:

<Files ~"[b]\.h[/b]t">
Order Deny,Allow
Deny from 192.168.0.1
</Files>

Also, you can specify files only, not directories. If you only want to limit files in a certain directory, then the <Files> directive must go in an .htaccess file in that directory. Alternately, you can put the whole thing inside a <Directory> container, but that's only available in httpd.conf, not .htaccess.

See the Apache documentation for details of using these directives.

Jim

robertito62

1:43 am on May 20, 2004 (gmt 0)

10+ Year Member



Excellent, thanks again!