// Is the method being specified? // if (sscanf($this->default_controller, '%[^/]/%s', $class, $method) !== 2) // { // $method = 'index'; // } $index = strripos($this->default_controller, '/'); // 记录 符号‘/’的下标 if($index == false) { $class = $this->default_controller; // 没有‘/’ 的可以直接赋值 }else{ $this->directory = substr($this->default_controller, 0, $index + 1); //目录的字符串 $class = substr($this->default_controller, $index + 1); //类的字符串 } $method = $this->method; //默认方法 ci3.0之前是可以放在 controllers中的子文件夹中的,但是到了ci3.0就必须直接放在 controllers下面,如果你坚持放在它的子文件夹下,那解决办法如下: 找到 system > core > router.PHP 2978-301 行注释掉。 ( 我的是 3.1.3版本 ) 如下: [php] view plain copy print? // if (sscanf($this->default_controller, '%[^/]/%s', $class, $method) !== 2) // { // $method = 'index'; // } 然后在后面添加如下代码: [php] view plain copy print? $index = strripos($this->default_controller, '/'); // 记录 符号‘/’的下标 if($index == false) { $class = $this->default_controller; // 没有‘/’ 的可以直接赋值 }else{ $this->directory = substr($this->default_controller, 0, $index + 1); //目录的字符串 $class = substr($this->default_controller, $index + 1); //类的字符串 } $method = $this->method; //默认方法 这样默认路由放在子文件夹下无法找到的问题就解决了。