doxn43207 2015-09-21 10:37
浏览 25

对codeigniter路线顺序感到困惑

I'm just learning about codeigniter and am stumped by the following:

I have these routes in my routes file:

$route['(:any)'] = 'pages/view';
$route['news/create'] = 'news/create';
$route['news/(:any)'] = 'news/view/$1';
$route['news'] = 'news';
$route['default_controller'] = 'pages/view';

Yet when i load http://mysite/index.php/news," it loads the news page rather than 'pages/view,'. I thought that because I have the catchall route at the top, this page would also just load pages/views.

Where am i going wrong?

  • 写回答

2条回答 默认 最新

  • dongyumiao5210 2015-09-21 10:47
    关注

    The reason is :any doesn't match slash, at least since CI 3.0+ . So your first route rule is not a "catch all" any longer. http://www.codeigniter.com/user_guide/installation/upgrade_300.html?highlight=any#routes-containing-any

    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度