I am using .htaccess to allow traffic from only one country. The code i am using is generated directly from ip2location.com.
But i still get traffic from countries that i am not allowing.
For example i have been using it to allow traffic from the UK only, but i still see traffic from Belgium and other European countries.
Why is this happening? Is the generator not up to date? Do i use .htaccess wrong?
Here is a shorter version of the .htaccess i am using (without the complete block of allowed ips generated from ip2location.com) :
<Limit GET HEAD POST>
order deny,allow
allow from 127.0.0.1/1
allow from 2.16.0.0/23
allow from 2.16.9.0/24
allow from 2.16.20.0/23
allow from 2.16.26.0/23
----------------------
allow from 67.14.63.53/32
deny from all
</Limit>
It's a bit hard to say considering you're leaving out the exact part of your .htaccess
that could let us figure out what's going wrong, but my guess is you're not going to be able to do what you want by filtering on IP alone. Your best bet might be to check the user's physical location by their IP address when they make a request. There's a chance that there are some IP's within the blocks you allow that are not within the UK.
That said, I'm not even sure why you'd want to do this. If you only want UK residents to use your service, there are much better ways to do this - such as requiring an account with a valid UK address. Your way has the downside of being easily circumvented (just use a proxy) and disallowing perfectly valid users whenever they're out of the country.