1

So I need to set a VirtualHost that have one domain to route clients to different applications depending on their IP address.

For example I want an american user that visits example.com to be served from /path/to/usa/application while users from different countries should be served from /new/international/application/path

1 Answer 1

4

You can do this with mod_geoip and mod_rewrite. Something like the following should do the trick:

DocumentRoot /new/international/application/path

GeoIPEnable On
GeoIPDBFile path-to-geoip.dat

RewriteEngine On
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^US$
RewriteRule ^(.*)$ /path/to/usa/application/$1 [L]

Requests from an IP address which the geoip module classifies as being in the US will be served from /path/to/usa/application, whereas other requests will be served from the default document root.

You must log in to answer this question.

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