How to block IP addresses from viewing my site?

This uses a .htaccess file which can be used to control some aspects of how your website runs.

Create a blank file on your computer and name it .htaccess and put the following lines into it (changing the IPs to suit your needs, each command on one line):

order allow,deny
deny from
deny from 123.12.3.
allow from all

You can deny access based upon a  single IP address or an entire range of IP addresses. The above example blocks access to the site from the IP address123.123.123.123, and from any IP address  under the IP range123.12.3. (,,, etc.)

You can also use deny from all (instead of allow from all) which will deny everyone. You can also allow or deny by a specific domain name instead of an IP address if you wish.

Just place this .htaccess file into your webroot folder (i.e. the folder you have all your website files located in).  If there is a .htaccess file in this folder then just add the lines you need to this file (some php applications create .htaccess files).  Please note that you can not and should not modify the .htaccess file directly in the webspace folder.