signature — 2009-12-21T16:24:12-05:00 — #1
I want to know how to block specific countries from certain pages of my website. I want to block 4 countries or so from just my main page and another page. Can this be done cleanly? If so how?
Note: I would like the other pages that I don't include to work
Much thanks in advance!
dan_grossman — 2009-12-21T16:56:48-05:00 — #2
Yes. Obtain an ip to location database (free ones are available, with lower accuracy than the paid versions), and use that to identify where the visitor is. You can either put the access logic in the pages (through some server side code which uses the database), or at the web server level (through MaxMind's mod_geoip for Apache).
signature — 2009-12-22T13:49:05-05:00 — #3
Thanks but I don't have the knowledge to implement that technology, is there an easier way?
felgall — 2009-12-22T14:05:33-05:00 — #4
That is about as easy as it gets to be able to do that. Of course you also need to keep the list up to date as IPs are occasionally moved between countries. Also there is nothing to prevent someone in a banned country using a proxy server in a country that isn't banned to be able to bypass the block.
signature — 2009-12-22T15:14:44-05:00 — #5
Thanks again, I'll try to get it to work with help from provider.
beyondit — 2009-12-24T09:15:14-05:00 — #6
I use htaccess to block out undesirable countries from accessing my website. Before you do something like this though I would consider the undesired impact that this could have for your legit visitors.
Even if your target demographic is local, you might be blocking out some legit visitors who are using AOL as their ISP. AOL uses proxies and someone visiting your website might live in your town, but the IP address they are connecting from could be coming from Europe... or anywhere. Still, there is good reason, in my opinion, to block out certain countries altogether. I know many on here would disagree, but some countries just have too much "bad" traffic to be trusted anymore. Use Google to find out more, I am unable to post links yet!
alan22 — 2009-12-24T10:26:13-05:00 — #7
Hi, if you don't want to use mod_geoip (and maxmind geo database) this site will generate .htaccess file for you:
linux7802 — 2009-12-27T05:30:04-05:00 — #8
In that case you need to block specific countries ip range....You can found out ip's by using following URL find-ip-address .org/ip-country/
dan_grossman — 2009-12-27T10:10:27-05:00 — #9
It'd be helpful if there was information, any information, about the source and accuracy of their data. For all I know they randomly generate it.
system — 2010-03-04T01:27:43-05:00 — #10
I think this one is more accurate:
At least IP2Location databases are updated every month.
system — 2010-03-23T05:49:41-04:00 — #11
If you are using WHM/cPanel then it is easy to block entire contry IP ranges from firewall like CSF. For more details how to block entire country in CSF visit following URL:
iprox — 2010-10-29T22:40:45-04:00 — #12
I have found that blocking countries is a very effective way to reduce spam as well. It is also a good idea to block the proxies that they use as well.
There are several ways to implement country blocking but it is always a good idea to use a solution that prevents problematic users from coming back.