![]() |
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'); Code: https://domain.com Code: https://domain.com/about-us Code: https://domain.com/admin/settings 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
The routes are iterated to the first match, so the URL https://domain.com/admin/settings will be handled by the second route.
You need to move the second route to the very bottom or assign a queue (priority) greater than 0 to it.
(08-18-2022, 10:40 AM)iRedds Wrote: The routes are iterated to the first match, so the URL https://domain.com/admin/settings will be handled by the second route. Thanks for the info. Kinda what I thought but needed confirmation! ![]()
It seems there is no clear description for route priority in the user guide,
I sent a PR: https://github.com/codeigniter4/CodeIgniter4/pull/6391
(08-18-2022, 06:31 PM)kenjis Wrote: It seems there is no clear description for route priority in the user guide, Thanks for doing that! @kenjis
(08-19-2022, 04:12 PM)kenjis Wrote: See https://codeigniter4.github.io/CodeIgnit...e-priority Nice! |
Welcome Guest, Not a member yet? Register Sign In |