How to do a conditional redirect based on source location
July 28, 2009 6:18 AM
Subscribe
How can I do a redirect based on a users location, but only for the landing page of a website and not subfolders or files?
We have a site: http://www.example.com. A country specific version of this site has been developed: http://aus.example.com/. This offers features specific to these users from Australia.
All traffic originating from Australia needs to be redirected to aus.example.com when visiting the landing page of http://www.example.com.
However, there are some special services provided by http://www.example.com:
http://www.example.com/freecarwash
http://www.example.com/submityourtaxes
These services are not provided by aus.example.com so all traffic to these pages need to be routed to www.example.com as usual.
In other words, how can I redirect only Australian traffic destined for the home page of http://www.example.com to aus.example.com but leave other traffic untouched.
Some relevant points:
1. The server for the subdomain aus.example.com is located in a different country to www.example.com.
2. A webserver / dns solution would be preferable to a page based solution.
posted by Gomez_in_the_South to computers & internet (5 comments total)
1) Identifying country of origin (this is hard). You really have no way of knowing where someone is coming from, even if you ignore issues like proxies. You might get 90%* certainty, and that's about it.
2) Redirecting from just that homepage to your target page (this is easy). The answer for this part depends entirely on your operating system and webserver software. A solution for IIS 7 will look different than one for IIS 6 which will look different from Apache ...
* number plucked from thin air
posted by adipocere at 6:24 AM on July 28