Link to home
Create AccountLog in
Avatar of duncanb7
duncanb7

asked on

Deny IP in .htaccess

Dear expert,
I would like to deny one IP address to visit my website to read all my directoy files
I tried to use the following .htaccess file  and ftp it into my public_html root directory.
=================================.htaccess file =============
# -FrontPage-
ErrorDocument 404 /blank.html
<Limit GET POST>
order deny,allow
deny from 63.238.185.242
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
=====================================
But it doesnt work any way even I reboot my VPS server.

COuld you tell how to make it success? Please advise
I am using apache Linux CentOS-64 system
Duncan
Avatar of duncanb7
duncanb7

ASKER

it work if I change order deny,allow to order allow,deny, Why could you explain it ?
ASKER CERTIFIED SOLUTION
Avatar of hielo
hielo
Flag of Wallis and Futuna image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
If you're trying to block someone who is trying to "attack" your site, you might want to consider using iptables to block the IP completely at the firewall level. That way you can easily block that IP (or more later) from everything, including FTP, mail, web, etc... It will be far more effective than .htaccess (and you can set up additional protection for yourself).
Yes, it is simple logic, thanks
Here's a template for the iptables rules. Basically, you will need to modify the parts about the IP addresses to include your IP address and the IP addresses you want to block. Then you load it with iptables-restore < file_containing_the_final_rules.txt
iptables-template.txt
So did you use htaccess or did you use iptables?
use .htaccess
For memo only:
========================
what is different bettween httpd.conf and .htaccess
http://www.webmasterworld.com/forum92/513.htm