CodeIgniter Forums
route group, only first one works - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: route group, only first one works (/showthread.php?tid=86268)



route group, only first one works - sjender - 01-25-2023

I am trying to group my routes in order to improve the readability.
But if I add a group, only the first one in the group seems to work.

PHP Code:
$routes->group('cms', static function ($routes) {
    $routes->get('/', [Dashboard::class, 'index']);
    $routes->get('/login', [Authentication::class, 'login']);
});

//$routes->get('/cms/', [Dashboard::class, 'index']);
//$routes->get('/cms/login', [Authentication::class, 'login']); 

When I un-escape the original routes, all works well, but in the group only /cms works.
Am I expecting something other than designed?
https://site/cms/login ends up with:
Code:
404 - File Not Found
Can't find a route for 'get: cms/login'.



RE: route group, only first one works - ikesela - 01-25-2023

remove / (backlash)
$routes->get('login', [Authentication::class, 'login']);


RE: route group, only first one works - sjender - 01-26-2023

Yes, that did the trick....
Thanks!