Webmasters Stack Exchange is a question and answer site for pro webmasters. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a web site. It is designed for two target groups of users: one from Eastern Europe, second - from USA. I also have two hosting accounts - one in USA and one in Europe.

I'd like to route the traffic in such a way that visitors from USA are pointed to hosting server in USA, while visitors from Europe are pionted to server in Europe. Is it possible to configure my DNS server (or whatever...) and how can it be done?

share|improve this question

migrated from superuser.com Feb 12 '13 at 16:59

This question came from our site for computer enthusiasts and power users.

The cheapest way to accomplish this would be to setup a sub-domain for each.

eu.yoursite.com and us.yoursite.com

Then when they first arrive on yoursite.com you can use a tool to determine their geolocation based on IP such as: http://www.ip2location.com/ or http://dev.maxmind.com/geoip/geolite

Set a cookie to direct them to the most appropriate subdomain.

Also html5 has a geolocation api.

share|improve this answer

Redirecting Visitors Based on Country Location in Apache2

This can be done easy in Apache2 by installing the Mod_geoip2 Apache Module, basically it connects to various API based GEO database providers and detect where the visitor is located, you can then use this collected data to redirect. A simple example of the .htaccess file would look like:

GeoIPEnable On
GeoIPDBFile /path/to/GeoIP.dat

# Redirect EU
RewriteEngine on
RewriteRule ^(.*)$ http://www.EU-Site.com$1 [R,L]

# Redirect Asia, North America and South America
RewriteEngine on
RewriteRule ^(.*)$ http://www.US-Site.com$1 [R,L]

As you can see this is a fairly easy task but your need to pay for up to date DATABASES and normally these are charged per X amount of requests. For the module it can be found here: mod_geoip2

share|improve this answer

Your Answer


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.