How to Block Unwanted Countries Website Traffic Certain Countries

How to Block Unwanted Countries Website Traffic Certain Countries

A pro reason to block unwanted countries. Save bandwidth especially on video site. Speed up your website and avoid spam when you block unwanted countries.

Block unwanted countries to save bandwidth/spam and other reasons.

There are many reasons why you may want to block visitors from a certain country. It could be that they are just wasting your bandwidth or for security reasons.

People may want to block geographical regions from accessing their websites.there are other reasons also because of spamming and attacks. But mostly because the traffic from some countries is of no benefit to your website. Allowing these visitors are just wasting bandwidth and making your site load slower for your real target country.

Block unwanted countries using the htaccess file.

Blocking visitors from regions that are useless to your website.This can be easily done using the htaccess file.What you will need to know the ip range that the visitors are arriving on your site from in order to deny them.

To get the ip address of all the countries that you may wish to block from your server. This may sound like much work. But on this site you can block a country, block by ip address, deny access by country. You will select which countries you wish to block. Next they will auto generate the code for you. Then and all you need to do is paste the code into your htaccess file .

Here is an Example on How to block visitors from Antarctica for example.

The code can be generated by ip2location or you can find the ip address by country here on wikipedia.

# -------------------------------------------------------
# Free IP2Location Firewall List by Country
# Source: https://www.ip2location.com/free/visitor-blocker
# Last Generated: 31 Jan 2021 21:10:15 GMT
# [Important] Please update this list every month
# -------------------------------------------------------
<Limit GET HEAD POST>
order allow,deny
allow from all
deny from 156.0.201.0/24
</Limit>

This will give unwanted visitors an ErrorDocument 403 Forbidden to keep your website traffic only from the countries you are targeting saving bandwidth or reducing spam.

Leave a Reply

Your email address will not be published. Required fields are marked *