views:

55

answers:

3

Hi

I hope you can help me.

I need to direct traffic to certian subdomains. EG

I live in RSA and we have 4 major cities.

Cape Town Johannesburg Eastern Cape Durban

I have the following sub domainds

capetown.mydomain.co.za johannesburg.mydomain.co.za durban.mydomain.co.za easterncape.mydomain.co.za

Now when some one opens my website from cape town, they must goto subdomain capetown.mydomain.co.za and vise versa.

Gum tree does it !

If you can help, it would be greatly appriated.

REgards Matthew

+1  A: 

You'll need to check the Ip adress of the visitor against an ip-location database. A quick google turned up this one: http://www.maxmind.com/app/csharp

Then you just redirect the request to the correct subdomain.

Lodewijk
A: 

You will need to subscribe to a GeoIP service that has detail down to the city level.

In your main page you would have a script that supplies the IP address to the GeoIP service and then do a redirect based on the city details returned.

Bing
A: 

Maxmind geolocation service can be very useful for the job. The Geolite free database only works with countries resolution, so you need to suscribe to the service in order to have more accurate information to obtain cities too.

Another IP location database provider: http://www.ip2country.net/

backslash17