开发者

Different Subdomains for Different Cities

I am developing a website using Codeigniter that will have different subdomains for different US cities, like Boston.mysite.com, NYC.mysite.com, Philadelphia.mysite.com just like Groupon, Yelp etc. However have never done this before and do not know how to achieve this! Assume my site currently mashes all the cities together but now I want to seperate them into different cities.

Question 1: How do I seperate my website into different cities, each with its own subdomain?

Question 2: Do I have need to duplicate my controllers, views, models for the different cities? What about the database? At this point I dont think there will be any difference in the site for the different cities except the database will not be shared among the different cities

开发者_如何学编程Question 3: Is using IP address a good way to find out which city a user is in so as to redirect the user to the different subdomains?


CodeIgniter subdomains are just folders parallel to the www folder in the site folder.

Example: /site/boston/htdocs

They could certainly all share the same database, as the database config is in the application/config and you could have the system folder setup for shared resources across all subdomains. You will still need to setup all the subdomains vhosts in apache.


I think this could be helpful. Was doing the same research and came across it. They recommend using the HTTP_HOST element of the built-in $_SERVER array

Same database & layout for multiple domains, but different logo on each

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜