Blocking IP Addresses in Apache

A common question I see being asked on various lists is “How do I block an IP address from accessing my site?”

This should *not* be treated as a robust security measure, there are many ways this could be bypassed. Use at your own risk.

Copy and paste the text below into a file and name it .htaccess. Then upload it to your web server.

order deny,allow
deny from nnn.nnn.nnn.nnn

(replace nnn’s with the IP address you wish to deny)

SHARE THIS POST

Share on facebook
Share on google
Share on twitter
Share on linkedin