$route['segment1/(:any)/(:any)'] = "myController/$1/$2";
in this case, I will have to link segment1/someMethod/someParam, but what if I don't have params in the url, i will need to write this:
$route['segment1/(:any)'] = "myController/$1";
$route['segment1/(:any)/(:any)'] = "myController/$1/$2";
thus the both cases will now work, so the question is: Can I write those 2 lines of code in one shot?
this:
$route['segment1/(:any)'] = "myController/$1";
$route['segment1/(:any)/(:any)'] = "myController/$1/$2";
is duplicating,they do the same thing, use just one of them, i suggest
$route['segment1/(:any)'] = "myController/$1";
hope to be clear, when using this "myController/$1" you are saying everything following myController/ should be routed, and it works also if no $1 params exists.
Definitely use just one of them and don't scare about not having params, it works like a charm ;)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With