子文件夹和路由内的控制器子文件夹

发布于 2025-01-01 07:15:10 字数 516 浏览 0 评论 0原文

在 Codeignitor 应用程序中

控制器/文件夹/子文件夹/子文件夹/my_controller.php

如果我想访问 my_controller.php 我不能这样做。为此,我确信我需要更改routes.php 文件来执行此操作。

$route['default_controller'] = "folder";
$route['folder/sub-folder/sub-folder'] = "folder/sub-folder/sub-folder/my_controller";

但显示 404 错误。

所以我的问题在控制器文件夹中很简单,如何有人可以使用文件夹内的文件夹。
像这样:

控制器/文件夹/子文件夹/子文件夹/my_controller.php

以及需要对routes.php 做什么,这样我就不会收到 404 错误。

In Codeignitor application

Controllers/folder/sub-folder/sub-folder/my_controller.php

if i would like to access my_controller.php i can't do this. for that i am sure i need change routes.php file to do this.

$route['default_controller'] = "folder";
$route['folder/sub-folder/sub-folder'] = "folder/sub-folder/sub-folder/my_controller";

but is showing 404 error.

so my question is simple in controller folder how someone can use folder inside folders.
like this:

Controllers/folder/sub-folder/sub-folder/my_controller.php

and what is needed to do with routes.php, so i will not get 404 error.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

來不及說愛妳 2025-01-08 07:15:11

我相信官方表格中有一个链接讨论了这一点。如果我没记错的话 CI 1.7 甚至不支持子目录并且最近才被包含,我认为他们仍然认为这是一个错误。

http://codeigniter.com/forums/viewthread/190563/

如果你只有几个子目录,您还可以在 URI 路由中放置规则

http://codeigniter.com/user_guide/general/routing.html

两者都可以接受,因此您可以选择哪一个对您帮助最大,或者哪一个完成得最快。另一个选择是研究为什么你需要这么多目录,特别是对于控制器来说,因为这会让你的 url 更长,这可能会给你带来 SEO 和其他因素的困扰。

I believe there is a link in the official forms talking about this. If I remember correctly CI 1.7 did not even support sub directories and was included recently and I think they still consider it a bug.

http://codeigniter.com/forums/viewthread/190563/

If you only have a few sub directories you can also put rules in your URI routing

http://codeigniter.com/user_guide/general/routing.html

Either will be acceptable so you can choose which one will help you the most or which will get done the fastest. The other option is looking into why you need so many directories, especially for the controllers because that will make your urls longer which could ding you on SEO and other factors.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文