CodeIgniter 2 not allowing multiple level subfolders for controllers

拟墨画扇 提交于 2019-12-23 15:06:32

问题


As I read the doc, controllers in CodeIgniter are supposed to support multiple level subfolders, but as far as I have tested, it is impossible to work after first a first level folder.

By example:

mysite.dev/ (index page, default controller home.php, works)

mysite.dev/admin/ (admin section, in admin/home.php, works)

mysite.dev/admin/manage/ (in admin/manage/home.php, do not work)

I am trying to know why and how to make it work on multiple level sub folders?

Thanks in advance!


回答1:


CI only allows one sub-dir level. However, you can emulate this pattern with routes file as @Brendan says:

Controllers:

welcome.php
admin/admin.php
admin/manage.php

Routes file:

$route['admin/manage/:any'] = "admin/manage/$1";
$route['admin/admin'] = 'admin/home.php';

You can implement some changes to the hardcode to get works as expected: http://codeigniter.com/forums/viewthread/190563/



来源:https://stackoverflow.com/questions/13240111/codeigniter-2-not-allowing-multiple-level-subfolders-for-controllers

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!