【问题标题】:PHP subdomain linked to controller?PHP子域链接到控制器?
【发布时间】:2010-01-19 04:27:42
【问题描述】:

我有一个在不同地理位置运营的网站。我的网站的一些示例 URL 是:

http://losangeles.example.com
http://sandiego.example.com/post/blog/travel/
http://sfbay.example.com/blog/read/12/

在这些示例中,我的 URL 结构被转换为以下内容:

http://[location code].example.com/[controller]/[event]/[extra parameters]

脚本剥离子域并根据数据库检查它是否存在可接受的位置匹配,然后显示该位置中的博客等。

这一切都很好,但现在我正在制作一个使用条款页面,我希望它有 URL:

http://about.example.com/tou

/* which is translated to: */

http://[controller].example.com/[event]

所以本质上,我希望子域有时是位置代码,有时是控制器。

知道我该怎么做吗?或者这只是愚蠢的?

【问题讨论】:

    标签: php model-view-controller routing


    【解决方案1】:

    我将创建一个路由到默认控制器的控制器异常列表。然后让您的默认控制器处理这些全局页面。

    【讨论】:

    • 我现在试一试这个
    【解决方案2】:

    如果.com/后面只有一个参数,区别对待,

    即,

    http://[location code].example.com/[controller]/[event]/[extra parameters]
    

    在 example.com 之后有 2 个或更多参数(控制器、事件、额外)

    http://[controller].example.com/[event]
    

    只有 1 个(事件)

    【讨论】:

    • 那一点也不差...除了我可能想传递额外的参数,你知道吗?
    猜你喜欢
    • 2012-05-01
    • 2011-01-08
    • 2011-10-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-17
    • 2014-11-14
    • 2012-10-18
    相关资源
    最近更新 更多