Codeigniter default route Error
Recently, codeigniter encountered an inexplicable bug. As follows:
Configure a default route in config/routes:
- $route['default_controller'] = "homePage/index";
As a result, Error 404 is returned when accessing the root url, while access/homePage/index is normal. If you have no idea, you can read the routing configuration code from the framework. This line of code in system/core/Router. php was suddenly realized.
- function _set_routing(){
- ...
- $this->default_controller = ( ! isset($this->routes['default_controller']) OR $this->routes['default_controller'] == '') ? FALSE : strtolower($this->routes['default_controller']);
- ...
- }
Strtolower is called here to convert default_controller to lower-case, and errors will occur when the method and class are read later. I don't know if this is a bug, but I am still interested in it.
The solution is that the default controller should not contain uppercase letters or remove the strtolower of this line of code in Router. php.