How to block an IP or service provider from viewing your website.

September 27, 08 by hozezero

Never thought I would need to do this, but sometimes you just have to.  This is how you can block an IP or service provider from viewing your website using .htaccess. Your .htaccess file is located at your root directory of your web hosting (server must be running Apache). If you do not have you, just create one.

.htaccess has many uses, in my case I have mine redirect any traffic to go from bluetomb.com to bluetomb.com/blog since that is where my content is.

To block an IP or service provider it is pretty easy. Simply add:

order allow,deny
deny from 192.168.0.1
deny from 192.168.0.2
deny from 192.168.0.3
deny from 127.0.0.
deny from genericISP.com
allow from all

What this will do is block IP’s 192.168.0.1-3, it also blocks any IP 127.0.0.0 -127.0.0.255, and will block any IP that genericISP.com is using. Most of the time blocking a whole range like 127.0.0.0-127.0.0.255 is a bit drastic, so use at your own risk. You may end up blocking legitimate users trying to view your site.

Thank you, Bluetomb

This entry no have comments... but you can be first.

Leave a Reply