Welcome to WebmasterWorld Guest from 54.226.46.6

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Block access to website by country?

     

brd1984

7:41 pm on Apr 23, 2011 (gmt 0)

5+ Year Member



Does anyone know of a good way to block access to a website, depending on what country the user is accessing it from? E.g. I only want to allow UK visitors access and block the rest of the world, and redirect them to a page.

I've had quite an extensive Google search and so far can only find this: [countryipblocks.net...] which lets you block whole regions via IP address, but you have to do it by individual IP addresses, which you put in your htaccess file - once done, the htaccess file was 3mb! Wayyy to big

And.. I've seen the HTML5 geo-location but it's only supported by new browsers.


Any ideas?

Thanks
Ben

lucy24

10:07 pm on Apr 23, 2011 (gmt 0)

WebmasterWorld Senior Member lucy24 is a WebmasterWorld Top Contributor of All Time Top Contributors Of The Month



Did you mean that literally? Allow one country, deny all (or just a few) others? In that case it seems like you'd be better off switching to "Deny,Allow" followed by "Deny from all" and then just a few lines for the ones you do want to let in.

g1smd

10:25 pm on Apr 23, 2011 (gmt 0)

WebmasterWorld Senior Member g1smd is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



The IP address method in the .htaccess file is the most efficient.

Be aware that blocking non-UK access will also remove your site from Google's index as they access from US-allocated IPs.

What about UK citizens abroad, on holiday, ex-pats, military, etc. Do you want to block all of them too?

sundaridevi

4:21 pm on Apr 25, 2011 (gmt 0)



the .htaccess method is quite cumbersome and not that accurate. The most accurate and up to date database is the maxmind.com paid geoip database. They also have a free version that is only 95% accurate.

If you use this, it's better to whitelist things than blacklist them. When you blacklist then when new IPs come (e.g. in a country you want to block), they won't be blocked until you update the database.

If you are implementing such a database with PHP or some scripting language, you could also choose to allow user-agent= googlebot to access your site. That would leave a backdoor for some guys who go around surfing as google bot, but there are some tradeoffs.

Another method would be to have a page somewhere that is not linked to anywhere on your site, and also not geo-blocked, then get it indexed by google, and then google bot can crawl your site via that url.
 

Featured Threads

Hot Threads This Week

Hot Threads This Month