crx349 发表于 2015-10-22 02:11:41

CodeIgniter 3.0 $config['enable_query_strings'] = true; 默认路由失效解决方案

当config.php设置为:
$config['enable_query_strings'] = true;
默认路由会失效:
解决方法1:
在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;
}

解决方法2:
CI 目录下写一个 index.html
<html>
<head>
    <meta http-equiv="Refresh" content="0;URL=index.php?c=index">
</head>
<body>
</body>
</html>
页: [1]
查看完整版本: CodeIgniter 3.0 $config['enable_query_strings'] = true; 默认路由失效解决方案