【问题标题】:How I can make and use custom url in cakephp我如何在 cakephp 中制作和使用自定义 url
【发布时间】:2013-11-19 05:33:15
【问题描述】:

我正在使用 cakephp 2.4.1,我想为我的项目制作以下网址。怎么可能?

http://example.com/privew/Homepage?=true 

http://example.com/privew?=true 。我是这样试的

Router::connect('/privew/*',array('controller'=>'Admin','action'=>'privew'));

但这无济于事。有谁知道怎么做的

【问题讨论】:

    标签: cakephp routing


    【解决方案1】:

    尝试删除 * 之前的多余斜线:

    Router::connect('/privew*',array('controller'=>'Admin','action'=>'privew'));
    

    另外我不知道你是否有控制器 Admin,但它应该是 'admins' 并且应该是小写的。

    【讨论】:

    • 我有 AdminController,我习惯在链接中写为'controller'=>'Admin'
    • 好吧,如果控制器文件是AdminController.php,那么它可以是Adminadmin
    【解决方案2】:
    Router::url(array(
    'controller' => 'posts',
    'action' => 'index',
    '?' => array('page' => 1),
    '#' => 'top'
    

    ));

    // 将生成一个类似的 URL。 /posts/index?page=1#top

    所以你可以这样尝试

    请参阅此处了解更多信息 http://book.cakephp.org/2.0/en/development/routing.html#Router::connectNamed

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-08-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-05-28
      • 2017-04-09
      • 1970-01-01
      • 2014-12-01
      相关资源
      最近更新 更多