Answer the question
In order to leave comments, you need to log in
How to configure ROUTE to pass one OR two parameters?
Good afternoon
, there is a url sitename.com/cat/1/2
where cat - product categories
1 - category number
2 - page (pagination)
in routes I write:
route['cat/(:num)/(:num)'] = " main/cat/$1/$2";
here
in the function
public function cat($id, $page=0)
BUT
if there is no page (1st page) - then the routes redirect to a 404 page ....
that is, it does not find the 2nd parameter because the link looks like sitename.com/ cat/1
how to set up routes correctly (make the 2nd parameter optional) ?
Or is my logic wrong at all?
Answer the question
In order to leave comments, you need to log in
route['cat/(:num)/(:num)'] = "main/cat/$1/$2";
route['cat/(:num)'] = "main/cat/$1";
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question