XILO Ltd. : Blog

Support 0333 773 3000 • Sales 0800 905 5000

BLOG

Our blog includes company news, recent announcements and upcoming service changes.

Blocking certain countries from viewing your website

We’ve added a sample rule that blocks 6 locations where we see the most comment spam originate from on our own community forums; Brazil, China, India, Indonesia and Russia. We’re also going to add a filter for Anonymous Proxies.

You will need to create a .htaccess file and upload this to the directory you want to protect, or if the whole site, create in public_html.

Our sample content looks like this:

RewriteEngine on

GeoIPEnable On
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^(A1|BR|CN|IN|ID|RU)$
RewriteRule ^(.*)$ http://www.google.co.uk$1 [L]

If the visitors IP address matches one of the counties listed on the “RewriteCond” line, it will then send them to http://www.google.co.uk as shown on the “RewriteRule” line. As it uses mod_rewrite, you could adapt this to only allow listed countries instead of rejecting them or even show specific content and languages for different regions.

When entering the country, the ISO code should be used. As an example, for United Kingdom you should use GB and not UK. There are also some addition codes to cover special locations as follows:

A1 - Anonymous Proxies
A2 - Satellite Providers
EU - Europe
AP - Asia and Pacific (ASIAPAC)
US - America but also includes overseas military bases regardless of country.

We hope you find this new feature very useful and this is one of many improvements that we are rolling out on all shared, reseller and premium hosting servers over the next few weeks.