![]() |
Autorouting is not working for Controller created inside sub-directory of Controllers - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Development (https://forum.codeigniter.com/forumdisplay.php?fid=6) +--- Forum: Issues (https://forum.codeigniter.com/forumdisplay.php?fid=19) +--- Thread: Autorouting is not working for Controller created inside sub-directory of Controllers (/showthread.php?tid=77142) |
Autorouting is not working for Controller created inside sub-directory of Controllers - wizardone - 07-24-2020 I have created a controller in a sub-directory under app/Controllers/Admin but unable to access it via autorouting methods like localhost/admin . The code for that is given below: PHP Code: <?php namespace App\Controllers\Admin; I think I have set up everything correctly from the docs. I have installed the ci4 using composer and adjusted the .env for development, added virtual host too. However, only custom route is working and also when I specify the whole directory for the controller like localhost/admin/admin. Code: /** Please Help if I made any silly mistakes or is this a bug? The error I am getting is : 404, the controller cannot be found RE: Autorouting is not working for Controller created inside sub-directory of Controllers - InsiteFX - 07-24-2020 You also need to pass along the sub-directory localhost/admin/admin RE: Autorouting is not working for Controller created inside sub-directory of Controllers - wizardone - 07-24-2020 (07-24-2020, 10:07 AM)InsiteFX Wrote: You also need to pass along the sub-directory But I have expanded the BaseController and also specified it's required namespace. It doesn't make sense to pass the sub-directory in the URL to get the controller. I should be able to gain the controller directly with localhost/admin, RE: Autorouting is not working for Controller created inside sub-directory of Controllers - jreklund - 07-25-2020 Your sub-controller needs to be named Home. As the auto route grabs your default controller name. App\Controllers\Admin\Home https://codeigniter.com/user_guide/incoming/controllers.html#organizing-your-controllers-into-sub-directories |