Welcome Guest, Not a member yet? Register   Sign In
Route Hierarchy (order)
#1

Not seeing an obvious answer to my question in the docs or forums, so....
I am wondering about routes and specifically how CI (4.2) handles two similar routes. Does it take the first one it comes across and stop processing the routes or does it keep reading and process the second one? 
Let's say I have the following routes (obviously not real, just for examples):

Code:
$routes->get('/', 'Home::index');
$routes->get('/(:any)', 'Home::cms_page/$1');
$routes->get('/admin/settings', 'Admin::settings');
Then I have the following URLs... what happens with each?
Code:
https://domain.com
I would expect this to match the first route. Would it?
Code:
https://domain.com/about-us
I would expect this one to match the second route. Would it?
Code:
https://domain.com/admin/settings
I would expect this one to match the third route, but concerned it would actually get processed on line 2.
In reading the docs, there is a short discussion about priority, would adding a level of say "5" to the first two all the third URL to process as intended? Or would it be better to just put the first two routes at the very bottom of the routes list?
TIA
Reply


Messages In This Thread
Route Hierarchy (order) - by SoccerGuy3 - 08-18-2022, 07:47 AM
RE: Route Hierarchy (order) - by iRedds - 08-18-2022, 10:40 AM
RE: Route Hierarchy (order) - by SoccerGuy3 - 08-18-2022, 11:06 AM
RE: Route Hierarchy (order) - by kenjis - 08-18-2022, 06:31 PM
RE: Route Hierarchy (order) - by SoccerGuy3 - 08-19-2022, 07:11 AM
RE: Route Hierarchy (order) - by InsiteFX - 08-18-2022, 11:37 PM
RE: Route Hierarchy (order) - by kenjis - 08-19-2022, 04:12 PM
RE: Route Hierarchy (order) - by SoccerGuy3 - 08-19-2022, 04:19 PM



Theme © iAndrew 2016 - Forum software by © MyBB