Use .htaccess to Block a Country
There are occasions when you need to do some serious blocking on your website, and you have to block an entire country. I have helped people in the past block countries like China from accessing their website. While there can be many reasons why you would want to block en entire country from accessing your website it used to be a bit of a chore to create the .htaccess file to do it. Well not anymore, check out block a country and with a couple of clicks you can generate an .htaccess file that will block the countries of your choice.
I have been playing with some screencasting software so I took a short screencast of how to use the site. Watch closely or you might miss it. If you feel like blocking off all of us friendly Canadians it only takes you a few seconds now.
After you either copy the information or download the generated .htaccess file all that is left to do is either upload it to your website or integrate it into your existing .htaccess file. It makes blocking a whole country very easy to do. I will definately use this tool the next time I get a call/email to block a country from access a website.
Comments
Evernoob
Looks cool, but how do I test it? I don't wanna inadvertently ban all the good people from say, Uzbekistan.
LGR
Well you could try to find a web proxy that is located in the country you want to block and surf to your website. Other than that, trial and error. Block a country and wait to see if they get rejected in your server log files.
miller
I know this is an old post, but I've been searching and I dont seem to be able to find, erm... well heres the deal: I'm looking to block pretty much everyone in my host country... but I kinda live here at the moment and still need access to my site for updating and maint. Its a public site for the rest of the world but people around here have a massive inferiority complex (which is part of the content).
LGR
You could do it as long as you know your IP address and it is relatively static. If your IP address changes regularly or then you would constantly have to be editing what IP address is allowed. Anyways. You could use the Block a Country htaccess generator then at the bottom just before <code>allow from all</code> You would have to whitelise your IP address. <code># whitelist your IP address allow from your.ip.address allow from all</code> Like I said though, if your IP changes regularly you would have to be editing this constantly.
Lito|UnProBlogger.Com
Nice tool but I was kind of having second thought if it will work. When I generate the .htaccess and saw the list of IP addresses, the IP address of my visitor from the country I wish to block is not there.