无限星辰工作室-客户无限互联网动力之源

标题: CodeIgniter 3.0 $config['enable_query_strings'] = true; 默认路由失效解决方案 [打印本页]

作者: crx349    时间: 2015-10-22 02:11
标题: CodeIgniter 3.0 $config['enable_query_strings'] = true; 默认路由失效解决方案
当config.php设置为:
  1. $config['enable_query_strings'] = true;
复制代码

默认路由会失效:
解决方法1:
在Function _set_routing()内将下面的代码提前放到这个函数内的前面:

  1. // Load the routes.php file.
  2. if (file_exists(APPPATH.'config/routes.php'))
  3. {
  4.     include(APPPATH.'config/routes.php');
  5. }

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

  10. // Validate & get reserved routes
  11. if (isset($route) && is_array($route))
  12. {
  13.     isset($route['default_controller']) && $this->default_controller = $route['default_controller'];
  14.     isset($route['translate_uri_dashes']) && $this->translate_uri_dashes = $route['translate_uri_dashes'];
  15.     unset($route['default_controller'], $route['translate_uri_dashes']);
  16.     $this->routes = $route;
  17. }
复制代码


解决方法2:
CI 目录下写一个 index.html
  1. <html>
  2. <head>
  3.     <meta http-equiv="Refresh" content="0;URL=index.php?c=index">
  4. </head>
  5. <body>
  6. </body>
  7. </html>
复制代码





欢迎光临 无限星辰工作室-客户无限互联网动力之源 (https://www.xmspace.net/) Powered by Discuz! X3.4