I just almost completed project in Codeigniter 4
and published it on hosting server. And now I am not able to access controller that is inside subdirectory.
For example: http://localhost/admin/auth/ - this URL works fine.
And when I access it on hosting server: http://x.someserver.com/admin/auth/
Then I am getting this error:
It's trying to load admin
controller which doesn't exist. Here is how my controllers are structured:
Note: Root.php
is my default controller.
I am not sure why this is happening. Or how can to resolve this. Here what I have found online similar issues.
One states that it needs to be namespaced.
The screenshot of your filesystem shows your admin/
directory is all lower case. It should start with a capital 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.
If you would rather use lower case a
, or if you simply want more transparent control of your routing, set up routes.