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'...
- Head to Country IP Blocks homepage.
- Select the countries you want to block or allow.
- 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.
- Click Create ACL.
- The ACL results will appear on the right side of your screen. Press the Copy ACL to Clipboard button.
- The ACL results will appear on the right side of your screen. Press the Copy ACL to Clipboard button.
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.