codeigniter 控制器子目录是否有限制?
您好,
我遇到了一个看似奇怪的问题,想知道是否有人能够阐明。
我创建了一个比传统 /application/controllers/ 目录低两层的简单控制器,当点击所述控制器时,我看到 CI 生成的 404。
详细来说,我的目录结构如下: /ci/application/controllers/dir1/dir2/myfile.php
该文件本身有一个带有 echo 语句的简单函数。当我将所述文件向上移动一级时,它位于: /ci/application/controllers/dir1/myfile.php
它有效。
我尝试更改上面示例中的“dir2”目录的名称、控制器的名称、控制器内的函数的名称——但无济于事。我能够在不通过 Code Igniter 框架的情况下访问同一个 php 文件,而且我在一台正常工作的 Windows 机器上,所以我无法想象这是一个与权限相关的问题。
我认为 CI 根本不愿意进入超过一级的控制器目录。 这可能吗,还是我错过了什么?
Greetings,
I've encountered a seemingly bizarre issue, and was wondering if anyone is able to shed a light.
I created a simple controller two levels down from the traditional /application/controllers/ directory and I'm seeing a CI-generated 404 when hitting said controller.
To elaborate, my directory structure is as follows:
/ci/application/controllers/dir1/dir2/myfile.php
The file itself has a simple function with an echo statement. When I move said file up one level such that it is located in:
/ci/application/controllers/dir1/myfile.php
It works.
I've tried changing the name of the "dir2" directory in the example above, the name of the controller, the names of the functions within the controller -- to no avail. I'm able to hit the same php file without going through the Code Igniter framework, and I'm on a Windows machine working normally so I can't imagine this to be a permissions-related issue.
I'm led to think that CI simply isn't willing to go into the controllers directory more than one level. Is this possible, or am I missing something?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
试试这个: http:// glnnpratama.wordpress.com/2009/10/20/multi-level-subfolder-for-controller-in-codeigniter/
基本上,您需要使用自己的 MY_Router 类覆盖默认的 codeigniter 路由器
Try this out: http://glennpratama.wordpress.com/2009/10/20/multi-level-subfolder-for-controller-in-codeigniter/
Basically, you need to override the default codeigniter router with your own MY_Router class
“开箱即用”,Codeigniter 仅支持控制器的单级目录结构。
有多种方法可以扩展默认 Router 类以启用此功能。
"Out of the box", Codeigniter only supports a single level directory structure for Controllers.
There are ways to extend the default Router class to enable this feature.