CodeIgniter Forums
404 on routes in sub folder - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forum-5.html)
+--- Forum: Model-View-Controller (https://forum.codeigniter.com/forum-10.html)
+--- Thread: 404 on routes in sub folder (/thread-77806.html)



404 on routes in sub folder - Vuader - 10-20-2020

I inherited a codeigniter website, and upgraded codeigniter. Figured out the controller files have to start with capital letters, and I got most of the routes and views working again. Except for the Admin portion of the site. The routes for this portion is not in the routes.php file, but in a different file. And the controllers is in a sub directory called admin, which I renamed to Admin. So even though there is for example an entry:

PHP Code:
$route['admin'] = 'admin/admin/index' 

When I go to /admin I get 404, and logs show:
Code:
404 Page Not Found: Admin/admin

I've even tried putting eg
PHP Code:
$route['admin/login'] = "admin/admin/login"
in the routes.php file, but I still see in the logs
Code:
404 Page Not Found: Admin/admin
even though:

Code:
$ grep admin config/routes.php
route['admin/login'] = "admin/admin/login";
$ grep login controllers/Admin/Admin.php
    public function login()
How can I troubleshoot these 404 errors in order to properly load the routes in the sub folder?


RE: 404 on routes in sub folder - InsiteFX - 10-21-2020

PHP Code:
/**
 * Begin Authentication Library Routes.
 */
$route['login']           "admin/admin/login";
$route['logout']          "admin/admin/logout";
$route['register']        "admin/admin/register";
$route['admin/dashboard'] = "admin/admin/index";
// End of Authentication Library Routes. 

The left side should be methods in your admin/Admin.php


RE: 404 on routes in sub folder - Vuader - 12-02-2020

Thanks for the advise InsiteFX

I added this to my routes.php:

PHP Code:
$route['admin/dashboard'] = "admin/admin/index"

However, when I visit /admin/dashboard, i am still getting 404 not found.

Any other suggestions?


RE: 404 on routes in sub folder - InsiteFX - 12-03-2020

Change it to below because it looks like you do not have a dashboard method in your Controller.

PHP Code:
$route['admin/dashboard'] = "admin/admin/index";

// change to
$route['admin'] = "admin/admin/index"