Codeigniter 4 routing with optional placeholder |
Hello,
I am fairly new to Codeigniter and have a problem with routing when passing a parameter. The problem is that the parameter I need to pass is a variable not always present. Essentially I need the following two cases to be valid when routing $routes->add('area-riservata','Areariservata::index'); $routes->add('area-riservata/(:any)','Areariservata::index/$1'); But cannot have them both at the same time in the Routes.php file. How can I have the above two cases coexist at the same time? Thanks for your help.
Try reversing the two routes because as soon as an exact match is found the routes stop searching
![]()
Such simple solution!! Works perfectly.
Thanks so much! You made me save a lot of time |
Welcome Guest, Not a member yet? Register Sign In |