1

I want to block all non UK visitors to my website, does anyone know how I would achieve this?

I think I need to have a .htaccess file with all the IPs listed next to a deny command but how do I find an upto date list of UK IPs to allow.

The reason for this is to try and reduce the amount of spam on my website.

Thanks for your help

4 Answers 4

9

Have a look at the GeoIP databases.

But i think to block ALL non UK visitors is not the best way. Imagine one of your users is in holidays autside the UK and want to reach your site.

Have a look at the DROP list from Spamhaus. It contains all Spammer owned networks. I use the list within my firewall rules, and reduced the SPAM about 98% on the hosted blogs.

2

Two solutions comes to my mind.

If your website is dynamic you can check en each request the country associated with the visitor ip using for example Maxmind GeoIP Database (http://www.maxmind.com/app/geolitecountry) if the user is not from UK just show a 404 or whatever you want.

The other solution is only allow users within a certain ip range access the website. You have to obtain the ip ranges for uk and then add them to the allow directive on the .htaccess file. The ranges can be obtained here (http://www.ipaddresslocation.org/ip_ranges/get_ranges.php)

1

What you want to do is typically called geolocation.

This question on StackOverflow has some useful answers.

0

Not sure that geolocation is a complete solution - nor that you shoul block access using .htaccess

That someone is publishing spam on your system implies that you've got some custom code running there - and AFAIK there's no easy way to do efficient lookups direct from the .htaccess file.

Certainly using geolocation may help - but you only need to control access to the bit of functionality which allows publishing of content. There's a free database you can run a local copy of available here.

If it were me, I'd use this as part of a scoring system, also incorporating

1) self-moderated posts - require user to provide an email address - when they post, don't publish until they click on a link you email to them

2) admin moderation - maybe you don't have time to moderate every post - but what about checking the first N posts from a particular user?

3) use spamassassin to identify spamming posts (NB the more spam posts you can capture (but obviously not publish) the better this will work)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .