This quick and easy tutorial will show you how to control site access based on visitors’ location. With some tweaks to the .htacess file, allowing or blocking visitors from certain countries is possible.

There are a number of useful tools available online which provide you with 'deny' lists, that can be added to your .htaccess file. In this article, we will be using 'Country IP Blocks'...

  1. Head to Country IP Blocks homepage.
  2. Select the countries you want to block or allow.
  3. Choose Apache .htaccess Deny or Apache .htaccess Allow in the Select Format section. The choice depends on whether you want to block or allow visitors from those countries.
  4. Click Create ACL.

    245aa1432d56b22da8bd1f4580d5c4e37696f8a9e9499605cd3f55c4381659a88943f3e429a4d2e9?t=089511629d341cae5aed6944cb0f4e87
    1. The ACL results will appear on the right side of your screen. Press the Copy ACL to Clipboard button.

      8f227dfa1ebe0430f15366a8111e9e3c6d73553c6706cf55146b171a1c433f3533a2d57d1a59d5c9?t=64855b4b2c249026a2e34ea4872527c4
  5. From here, you will need to just paste the contents of the ACL into your .htaccess file. If you have contents already, its usually best to paste the contents after the rest of your .htaccess contents.