Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

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.

2 Answers 2

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
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^EU$
RewriteRule ^(.*)$ http://www.EU-Site.com$1 [R,L]

# Redirect Asia, North America and South America
RewriteEngine on
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^(NA|SA|AP)$
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

 
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.