How to setup a route for an optional second param? |
Do I need to setup two rules in the Routes.php for these two urls?
Code: 1) http://mydomain.example/show-list PHP Code: Rule 1) $routes->add('show-list', 'Home::index'); PHP Code: //HomeController.php If I have only this rule Code: $routes->add('show-list', 'Home::index'); If I have only this rule Code: $routes->add('show-list/(:any)', 'Home::index');
Yes I already tried and it throws up error too.
The only way I can get working is by using a regular expression with an optional flag.
Did you try it like this?
According to the doc's the $1 has to go into the quotes. PHP Code: $routes->add('show-list/(:any)', 'Home::index/$1'); Not tested. What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
|
Welcome Guest, Not a member yet? Register Sign In |