The first route will be catching all of the requests that start with category_
, including any that should be routed to the second route. This is because (:any)
will catch anything, including multiple parameters, so the second route would never be used in this order.
Routes will run in the order they are defined. Higher routes will always take precedence over lower ones.
You just need to change the order of the routes:
$route['category_(:any)/(:any)'] = 'category/categoryDemandeDetails/$1/$2';
$route['category_(:any)'] = 'category/categoryDetails/$1';