October 17th, 2014
If you own a website or a blog, you know the awesome feeling when you get good traffic. This blog title might get you to ask a question, why in the world will anyone want to block an entire country from their website. Well you’ll be surprised to know that there are many out there who are actually blocking particular countries from their website. Some are targeting their website to specific countries and don’t want traffic from other countries to better manage their server resources while others just don’t want to deal with certain countries for their known spammers or hackers crowd[E.g. China accounts for nearly 41% of the total cyber attacks that were made around the world]
If you’re looking to block an entire country from your website then you’re in luck. We’re going to share the steps on how you can block countries from your website using your .htaccess file.
How to block a country from your website using the .htaccess file
1] First you need to find the list of IPs for the country that you need to block. To find this, visit http://www.ip2location.com/free/visitor-blocker. Select the country that you wish to block and then choose the output format as Apache .htaccess deny and then download the file.
2] Now log into your cPanel
3] Click on File Manager and then select the Web Root radio button. You need to ensure that SHOW HIDDEN FILES is checked. Then click on GO to access the files.
4] Here you need to look for .htaccess file. Once you’ve located it, right click on the file and click on Edit.
5] Once you’re in the .htaccess editor, simply copy the code from the file that you downloaded in Step 1 and paste the code here. Click on Save to ensure the code is saved in the file. [Note: Selecting popular countries can result into thousand lines in block code]
That’s it, now any visitor from the IP range that you’ve added in the .htaccess file will not be able to access your website. We recommend that you take extra precaution while trying these steps.
Have any questions? Feel free to drop a comment below and we’ll answer your questions.