Home » How to Block Unwanted Countries Website Traffic Refuse Certain Countries

How to Block Unwanted Countries Website Traffic Refuse Certain Countries

    A pro reason to block unwanted countries. Save bandwidth especially on video sites and music streaming sites. Speed up your website and avoid spam when you block unwanted countries. For Example, if you were running a service like the internet speed test ookla but only wanted users from one country using the tool then you could use these htaccess rules to block 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. Other reasons are spamming and attacks so it’s a security measure also. 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 is 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

    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. Or in the case of Youtube, You will get this notice.

    Youtube Blocked by Country
    Blocked Access By Country on Youtube

    Leave a Reply

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