CI 3.0 default route is placed in a subfolder inaccessible workaround

Source: Internet
Author: User
Tags vars
This article goes from:
Let's say you want to configure the default route to: $route [' default_controller '] = ' index/home ';

ci3.0 before can be placed in the Controllers subfolder, but to the ci3.0 must be placed directly under the controllers, if you persist in its sub-folder, the solution is as follows:

Locate System > Core > Router. Comment out the PHP 2978-301 line. (My version of 3.1.3) is as follows:

    1. if (sscanf ($this->default_controller, '%[^/]/%s ', $class, $method)!== 2)

    2. // {

    3. //$method = ' index ';

    4. // }

Then add the following code:

  1. $index = Strripos ($this->default_controller, '/'); //The subscript of the record symbol '/'

  2. if ($index = = False)

  3. {

  4. $class = $this->default_controller; //No '/' can be directly assigned

  5. }else{

  6. $this->directory = substr ($this->default_controller, 0, $index + 1); //directory string

  7. $class = substr ($this->default_controller, $index + 1); //String of class

  8. }

  9. $method = $this->method; //default method

This solves the problem that the default route cannot be found under sub-folders.

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: 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.