Localising content with GeoIP and Apache

Posted

Today I came across a page on MaxMind's site which shows some of the things you can do using mod_geoip (the GeoIP Apache module). Using the GeoIP data in applications isn't rocket science anyway, but the Apache module allows you to do some fairly funky stuff all server-side. E.g. say you had a download site with a few mirrors in different parts of the world, you could automatically redirect users to the correct one with something like:

GeoIPEnable OnGeoIPDBFile /path/to/GeoIP.datRewriteEngine on
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^US$
RewriteRule ^(.*)$ http://us-mirror.mydomain.com$1 [L]
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^GB$
RewriteRule ^(.*)$ http://uk-mirror.mydomain.com$1 [L]

and so on.

Comments (0) Tags: GeoIP, apache

Add Comment

(Never shown on the site)

(Newlines preserved, format with Markdown)