This may be controversial for some, but there is nothing to stop you from limiting access to your website by IP addresses. There are various ways to lock down a website using the .htaccess file. This is simple to do and effective.
Reasons to Block Countries by IP \ .htaccess
This is an extremely powerful file. It is simple to use, but done wrong it can break your website, so be careful and if in doubt, ASK!
The primary purpose of this post is to explain how to generate a .htaccess file in order to block countries by IP. Rather than build a list of countries which are allowed, we are going to build a list of those which are NOT.
One of our clients runs a typical small business website. His bandwidth over the last couple of months has tripled and it’s all coming from Pakistan. We asked the question “are you doing lots of business in Pakistan” to which the reply was, No.
So, we can see something is wrong. A website has gone from using 6GB per month in bandwidth, to 30GB and 24GB per month is being used by Pakistan… Time to block them…
OK, we recommend using a website by Incredibill. It’s a handy .htaccess builder which lets you select the countries you wish to block, press a button and download a file. Simply upload the .htaccess file and watch the traffic drop.
IMPORTANT: Check to see if you have an .htaccess file already. The chances are, you will do. You must NOT replace the .htaccess file and instead, you need to append the contents of the new file to the original one. Just open the file, copy and paste the contents into the new one.
Steps to Follow
- Visit the Incredibill website
- Click on the relevant countries you wish to block
- Click ‘generate’ htaccess button
- Copy the provided code and list of IP’s (CTRL C or CMD C)
- Paste the provided code into the existing .htaccess file at the bottom (CTRL V or CMD V)
IF you do not have .htaccess file already, simply create one and paste the data into it. NOTE: Some FTP clients may not show you files which are pre-fixed with a . NOTICE that this file is not htaccess it is .htaccess
USE THIS AT YOUR OWN RISK.
We use it and it works well. It is your choice, but if you are suffering with spam or bogus orders from pesky countries and you know for certain, that you will never do business in that country, block them! It is an effective way to combat countries who cause problems.