用户
 找回密码
 入住 CI 中国社区
搜索
查看: 3610|回复: 0
收起左侧

[版本 3.x] 關於 3.0 的預設路由

[复制链接]
发表于 2015-4-18 11:17:39 | 显示全部楼层 |阅读模式
本帖最后由 Closer 于 2015-4-18 11:33 编辑
Directories and ‘default_controller’, ‘404_override’
As you should know, the $route['default_controller'] and $route['404_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 documented. If you’ve relied on it, your application will break with CodeIgniter 3.0.

Another notable change in version 3 is that ‘default_controller’ and ‘404_override’ are now applied per directory. To explain what this means, let’s take the following example:

$route['default_controller'] = 'main';
Now, assuming that your website is located at example.com, you already know that if a user visits http://example.com/, the above setting will cause your ‘Main’ controller to be loaded.

However, what happens if you have an application/controllers/admin/ directory and the user visits http://example.com/admin/? In CodeIgniter 3, the router will look for a ‘Main’ controller under the admin/ directory as well. If not found, it will fallback to the parent (application/controllers/) directory, like in version 2.x.

The same rule applies to the ‘404_override’ setting.

上列內容來自於 CI 英文官網 - Upgrading from 2.2.x to 3.0.0

已經有說明,預設路由和 404 路由
當初開發理念並沒有希望用一級目錄來訪問
所以此項功能在 3.0 已取消
別再問為什麼預設路由設置不成功了
他就是不支援一級目錄

如果你堅持要,就是得在進入預設路由的控制器中重新轉址!
PHP复制代码
 
$this->load->helper('url');
redirect(site_url('login/form'), 'refresh');
 
复制代码


本版积分规则