How to ban people from your site by IP address

I found this neat trick the other day… If you notice someone is trying to hack your website, or just would rather a certain individual not stop by anymore, its very easy to ban the offender if you’re using Apache as your webserver.

  1. Create a file in the top-level directory of your website – the same one that contains the index or “main page” of your site. Name this file “.htaccess”
  2. Put the following code in the file:
    order allow,deny
    deny from 192.168.0.1
    allow from all
  3. Replace “192.168.0.1″ with the ip address of the person you’re trying to block. If you’d like to block multiple IP addresses, add as many deny from <ip address> lines as you want under the first, right above allow from all.

If you enjoyed this post, make sure you subscribe to my RSS feed!

Leave a Reply