【问题标题】:How can I do this kind of routing in CakePHP?如何在 CakePHP 中进行这种路由?
【发布时间】:2012-12-13 19:11:21
【问题描述】:

我有一个这样的链接:

www.mydomain.com/users/view/1

但我希望用户去:

www.mydomain.com/profile/1

当他们键入/单击第一个链接时。我已经阅读了这个页面,我可以用它做一些基本的东西,但我仍然无法弄清楚这个:

http://book.cakephp.org/2.0/en/development/routing.html

感谢您的帮助和解释(我使用的是 2.x 版)。谢谢。

【问题讨论】:

    标签: cakephp routing


    【解决方案1】:

    有人告诉我使用它并且它有效:

    Router::connect(
        '/profile/:id', 
        array('controller' => 'users', 'action' => 'view'), 
        array('id' => '[0-9]+', 'pass' => array('id'))
    );
    

    现在/profile/1 完成/users/view/1 的工作。

    【讨论】:

      猜你喜欢
      • 2023-03-23
      • 2011-07-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-14
      • 2016-10-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多