Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

share|improve this question

1 Answer 1

up vote 4 down vote accepted

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.