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.

    1. The ACL results will appear on the right side of your screen. Press the Copy ACL to Clipboard button.

  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.