Yes, you can block visitors per their IP address. Countries will have a specific IP address range, and you can use that information to block all or some of their IP’s. There are more than one way to do this:
Searching the internet, we found a unique solution for blocking countries and regions via IP addresses with some PHP coding.
Visit http://timtrott.co.uk/block-website-access-country for more details about this method, including example code.
Another way to do it is to block IP ranges in the .htaccess file for your site.
For a current list of IP addresses by country, please visit http://www.countryipblocks.net/
On the resulting page, click the “.htaccess deny” link for the desired country. This is the exact code you should paste in your .htaccess file.
Usually the .htaccess in your webpage/ folder is best, as it can protect all your addon domains and subdomains.
To block multiple IP addresses, list them one per line by editing your .htaccess file, for example:
You can also block an entire IP block/range. Here we will not specify the last octet in the .htaccess file.
This will refuse access for any user with an address in the 127.0.0.0 to 127.0.0.255 range.
Instead of using numeric addresses, domain names (and subdomain names) can be used to ban users.
It bans users with a remote hostname ending in isp_name.com. This would stop all users connected to the internet via isp_name.com from viewing your site.
If you only want to allow certain IPs to connect to your website, you can set an option for deny from all, which will deny everyone.
This must be done by coding your .htaccess file as follows:
deny from all
allow from 70.24.291.52
allow from 188.8.131.52 #my house
Using .htaccess to block an entire range or name is likely to lock out innocent users. Use with caution.
Copyright © 2000-2016 Imageway Digital Media | All rights reserved