Codeigniter default route Error

Source: Internet
Author: User

Codeigniter default route Error

Recently, codeigniter encountered an inexplicable bug. As follows:

Configure a default route in config/routes:

 
 
  1. $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.

 
 
  1. function _set_routing(){   
  2. ...   
  3. $this->default_controller = ( ! isset($this->routes['default_controller']) OR $this->routes['default_controller'] == '') ? FALSE : strtolower($this->routes['default_controller']);   
  4. ...   
  5. }   

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.