远程服务器上无法访问 Codeigniter 4 子目录控制器
Codeigniter 4 subdirectory controller not accessible on remote server
我几乎要在 Codeigniter 4
完成项目并将其发布到托管服务器上。现在我无法访问子目录中的控制器。
例如:
http://localhost/admin/auth/ - 这个 URL 工作正常。
当我在托管服务器上访问它时:
http://x.someserver.com/admin/auth/
然后我收到这个错误:
它正在尝试加载 admin
不存在的控制器。以下是我的控制器的结构:
注意:Root.php
是我的默认控制器。
我不确定为什么会这样。或者如何解决这个问题。
这是我在网上发现的类似问题。
有人说它需要命名空间。
文件系统的屏幕截图显示您的 admin/
目录全部为小写。它应该以大写 A
开头。 From the docs:
Organizing Your Controllers into Sub-directories
If you are building a large application you might want to hierarchically organize or structure your controllers into sub-directories. CodeIgniter permits you to do this.
Simply create sub-directories under the main app/Controllers/
one and place your controller classes within them.
Important
Folder names MUST start with an uppercase letter and ONLY the first character can be uppercase.
如果您更愿意使用小写 a
,或者如果您只是想更透明地控制您的路由,set up routes。
我几乎要在 Codeigniter 4
完成项目并将其发布到托管服务器上。现在我无法访问子目录中的控制器。
例如: http://localhost/admin/auth/ - 这个 URL 工作正常。
当我在托管服务器上访问它时: http://x.someserver.com/admin/auth/
然后我收到这个错误:
它正在尝试加载 admin
不存在的控制器。以下是我的控制器的结构:
注意:Root.php
是我的默认控制器。
我不确定为什么会这样。或者如何解决这个问题。 这是我在网上发现的类似问题。
有人说它需要命名空间。
文件系统的屏幕截图显示您的 admin/
目录全部为小写。它应该以大写 A
开头。 From the docs:
Organizing Your Controllers into Sub-directories
If you are building a large application you might want to hierarchically organize or structure your controllers into sub-directories. CodeIgniter permits you to do this.
Simply create sub-directories under the main
app/Controllers/
one and place your controller classes within them.Important
Folder names MUST start with an uppercase letter and ONLY the first character can be uppercase.
如果您更愿意使用小写 a
,或者如果您只是想更透明地控制您的路由,set up routes。