CI3.0 默认路由问题 解决办法

2021-07-09 11:25:13 浏览数 (1)

当开查询字符串的时候,参数enable_query_strings 为 true 。首页报错

An Error Was Encountered Unable to determine what should be displayed. A default route has not been specified in the routing file.

解决办地,修改文件 system/core/Router.php

_set_routing 函数内前面加

代码语言:javascript复制
// 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;
    }

0 人点赞