首页 > 其他 > 详细

ci 3.0 默认路由放在子文件夹 无法访问的解决办法

时间:2017-06-21 17:26:32      阅读:231      评论:0      收藏:0      [点我收藏+]
比方说你想配置默认路由为: $route[‘default_controller‘] = ‘index/home‘;

 

ci3.0之前是可以放在 controllers中的子文件夹中的,但是到了ci3.0就必须直接放在 controllers下面,如果你坚持放在它的子文件夹下,那解决办法如下:

找到 system > core > router.PHP  2978-301 行注释掉。 ( 我的是 3.1.3版本 ) 如下:

 

技术分享

 

  1. // if (sscanf($this->default_controller, ‘%[^/]/%s‘, $class, $method) !== 2)  
  2.         // {  
  3.         //  $method = ‘index‘;  
  4.         // }  

 

然后在后面添加如下代码:

技术分享

 

 

  1. $index = strripos($this->default_controller, ‘/‘);  // 记录 符号‘/’的下标  
  2.         if($index == false)  
  3.         {  
  4.             $class = $this->default_controller; // 没有‘/’ 的可以直接赋值  
  5.         }else{  
  6.             $this->directory = substr($this->default_controller, 0, $index + 1); //目录的字符串  
  7.             $class  = substr($this->default_controller, $index + 1);  //类的字符串  
  8.         }  
  9.         $method = $this->method;  //默认方法  


 

这样默认路由放在子文件夹下无法找到的问题就解决了。

ci 3.0 默认路由放在子文件夹 无法访问的解决办法

原文:http://www.cnblogs.com/Mahon-Zone/p/7060720.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!