How do I make a website with subdomains catering to different cities?
Like http://philly.example.com
, http://maine.example.com
, http://sandiego.example.com
? Most of the site will be the same, like the layout, the wordings, the database, the interface. What will be different will be some city-specific graphics like adding a city name to the logo (eg. Groupon Nyc, Groupon Chicago), changing a hidden variable (city) in the form that searches the database so results will be biased towards the city.
Question 1. User visits site. Script determines city from user's IP address then redirect to the correct subdomain.
I can do the detection script, but how do you display almost the same site to each of the different city? I guess you do not duplicate the site 50 times for 50 different cities, handling the changes to every site will be insane!
Question 2: Assuming you do not duplicate the site each time for a new city and change the images and text slightly, how do you do the city-specific changes then?
Do you have a list of 50 case-ifs
or if-elseif-else
for every city-specific item on the page? I foresee doing this will mess up the code for the entire page!