I’m just starting with Codeigniter. I created a simple controller called home.php and a view called home_view.php. This is working fine. Now I would eventually like this site I’m building to have a admin section in addition to the public www version. So I reorganized my file structure like so:
controllers:
www
- home.php
admin
Views:
www
- home_view.php
admin
Eventually I will put the admin related controllers and views in their respective directories. But after having moved my files like so, they no longer work. I think I need to changes something in the routes or config file. What do I have to do?
For the views you just need to add the folder name to the begin of the view like:
You will probably need to redo the routing for the controllers, so that extra folders are accounted for. This can be done with something like the following:
This will use the controller($1) and function($2) inside the admin folder if the url is http://www.example.com/index.php/admin/%5Bcontroller%5D/%5Bfunction%5D
for the controllers in the admin folder;
and update the default controller like this: