Welcome Guest, Not a member yet? Register   Sign In
Codeigniter 4 routing with optional placeholder
#1

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.
Reply
#2

Try reversing the two  routes because as soon as an exact match is found the routes stop searchingSmile
Reply
#3

Such simple solution!! Works perfectly.
Thanks so much! You made me save a lot of time
Reply




Theme © iAndrew 2016 - Forum software by © MyBB