我有一个在不同地理位置运营的网站。我网站的一些示例网址是:
http://losangeles.example.com
http://sandiego.example.com/post/blog/travel/
http://sfbay.example.com/blog/read/12/
在这些示例中,我的网址结构已转换为以下内容:
http://[location code].example.com/[controller]/[event]/[extra parameters]
脚本剥离子域并将其与数据库进行检查以获得可接受的位置匹配,然后显示该位置的博客等。
这一切都很好,但现在我正在制作使用条款页面,我希望它有URL:
http://about.example.com/tou
/* which is translated to: */
http://[controller].example.com/[event]
基本上,我希望子域有时候是位置代码,有时候是控制器。
知道我怎么做这个吗?或者这只是愚蠢的?
答案 0 :(得分:0)
我将创建一个路由到默认控制器的控制器异常列表。然后让您的默认控制器处理这些全局页面。
答案 1 :(得分:0)
如果.com/
之后只有一个参数对待它,
即,
http://[location code].example.com/[controller]/[event]/[extra parameters]
在example.com之后有2个或更多参数(控制器,事件,额外)
和
http://[controller].example.com/[event]
只有1(事件)