用户
 找回密码
 入住 CI 中国社区
搜索
12
返回列表 发新帖
楼主: LUISHOU
收起左侧

[版本 3.x] 升级到3.0出现了404错误

[复制链接]
发表于 2015-5-18 12:22:51 | 显示全部楼层
我也出现这种情况,URL有设置参数是正常 如:indxe.php?c=Welcome;要是未设置参数 如直接访问index.php默认的控制器没有生效,显示:
Unable to determine what should be displayed. A default route has not been specified in the routing file

最后查看代代码发现在system\core\Router.php中未给$this->default_controller赋值,获取不到默认的控制器。



解决办法:
Function _set_routing()内将下面的代码提前放到这个函数内的前面:

// Load the routes.php file.
if (file_exists(APPPATH.'config/routes.php'))
{
    include(APPPATH.'config/routes.php');
}

if (file_exists(APPPATH.'config/'.ENVIRONMENT.'/routes.php'))
{
    include(APPPATH.'config/'.ENVIRONMENT.'/routes.php');
}

// Validate & get reserved routes
if (isset($route) && is_array($route))
{
    isset($route['default_controller']) && $this->default_controller = $route['default_controller'];
    isset($route['translate_uri_dashes']) && $this->translate_uri_dashes = $route['translate_uri_dashes'];
    unset($route['default_controller'], $route['translate_uri_dashes']);
    $this->routes = $route;
}
发表于 2015-5-18 15:01:24 | 显示全部楼层
我在linux下面测试了,必须class首字母大写,切文件名与class一样首字母也要大写,举个例子,一个Welcome的类,如果你文件名是welcome而类名是Welcome这样是访问不到这个控制器的必须同时两个都是Welcome才可以

本版积分规则