About CodeIgniter3.0default _ controller

Source: Internet
Author: User
When I was in CI2.x, under the controller directory, there were two directories, admin and index, respectively, corresponding to the background and foreground. In routes. php, the {code...} that I set in this way is now found in 3.0. This setting cannot work. What should I do. What is quite tangled is that I do...

When I was in CI2.x, under the controller directory, there were two directories, admin and index, respectively, corresponding to the background and foreground.

I set routes. php in this way.

$route['default_controller'] = 'index/home/index';

It is found that in 3.0, this setting does not work. What should I do. I really want to put the foreground under the index DIRECTORY instead of directly moving it to the upper-layer controller.

How can I access index. php with the existing directory structure? The default controller is index/home/index.

In addition, I don't want to jump over through redirect, because it does not show index. php, but exposes the full path.

Reply content:

When I was in CI2.x, under the controller directory, there were two directories, admin and index, respectively, corresponding to the background and foreground.

I set routes. php in this way.

$route['default_controller'] = 'index/home/index';

It is found that in 3.0, this setting does not work. What should I do. I really want to put the foreground under the index DIRECTORY instead of directly moving it to the upper-layer controller.

How can I access index. php with the existing directory structure? The default controller is index/home/index.

In addition, I don't want to jump over through redirect, because it does not show index. php, but exposes the full path.

Official documentation

Directories and 'default _ controller', '2017 _ override'
As you shoshould know, the $ route ['default _ controller'] and $ route ['2014 _ override'] settings accept not only a controller name, but also controller/method pairs. however, a bug in the routing logic has made it possible for some users to use that as directory/controller instead.
As already said, this behavior was incidental and was never intended, nor has ented. If you 've relied on it, your application will break with CodeIgniter 3.0.

It can be seen that the official Team regards this as a BUG and does not recommend this practice.

You do not want to display index. php; Configuration:config.phg

$ Config ['index _ page'] = ''; // remove index. php
Add in root directory .htaccess
 RewriteEngine on RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond $1 !^(index\.php|assets|robots\.txt) RewriteRule ^(.*)$ /index.php/$1 [L]

In addition, your configuration should be$route['default_controller'] ='index/home';

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.