Semalt Explains How To Block Some Countries From Accessing Your Site
If you own a website or blog, you must be familiar with the fact that it is accessible to all the countries by default. Various sites are not relevant to the people in other states, so we should not expect the significant traffic and visits from them. For instance, if you have a local bookshop and your market is people of your own country, then you don't need to let other countries waste the bandwidth of your server.
There are various reasons why blocking access to certain countries is necessary. The best reason is that your site will cater only to the local people and has nothing to do with the outsiders, so you can stop Google, Bing, and Yahoo from indexing your site for those states. Here, Ross Barber, the Semalt Customer Success Manager, has discussed the most common methods to block countries:
1. The .htaccess file
If you are a webmaster, you might know that editing .htaccess file can benefit your site in a lot of ways. The legit hackers and spammers use proxies and bot farms to perform their tasks. A webmaster, however, can block the suspicious IP addresses so that the hackers cannot do naughty things online. Your .htaccess file is likely to grow to thousands of lines of text if you block the unwanted countries. For this, you just need to place a specific code in the .htaccess file, and the code is:
Order Deny, Allow
Deny from 220.127.116.11
Deny from 18.104.22.168
Deny from 22.214.171.124
2. Use the hosting company with blocking services
You can use the hosting service that offers different country blocking services. GoDaddy is the only hosting company that offers this service at reasonable monthly prices.
3. Bare Metal
A bare metal, also called VPS, is the machine that you can use to block the unwanted countries. From the software firewall to the hosting service and the control panel, the bare metal brings everything to your hands. Three prominent bare metal options you can go with are DigitalOcean Droplet, Rackspace, and InMotionHosting. Google their names and check details.
4. Use Your cPanel IP blockers
The hosting company you are using can help you to block the IP addresses via the control panel. You can contact them directly and ask them to install an IP blocker on your cPanel so that you can block the IPs of the countries you don't want to receive traffic from.
5. Geoblocking or Geo Restriction
Geo Restriction lets us select the countries we want to restrict access to. By configuring the whitelist or the blacklist of those countries, you can easily control the delivery of your web content via Amazon CloudFront. Akamai is another option to go with. If you have the CDN delivering your web content, you must be worried about the meaningless use of your bandwidth. Pay attention to the Geoblocking services and get the things done perfectly.
6. Apache Modules
If you have the Apache modules, you won't need to fill the .htaccess file with lots of lines of IPs. MaxMind provides us with the free database that we can use to block the unwanted or suspicious IPs. Its GeoLite2 is the best option to go with and is free of cost.