: How can I route traffic between two hosting servers? 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
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?
More posts by @Pope3001725
2 Comments
Sorted by latest first Latest Oldest Best
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 ^(.*)$ www.EU-Site.com [R,L]
# Redirect Asia, North America and South America
RewriteEngine on
RewriteCond %{ENV:GEOIP_COUNTRY_CODE} ^(NA|SA|AP)$
RewriteRule ^(.*)$ www.US-Site.com [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
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: www.ip2location.com/ or dev.maxmind.com/geoip/geolite
Set a cookie to direct them to the most appropriate subdomain.
Also html5 has a geolocation api.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.