Welcome Guest, Not a member yet? Register   Sign In
Codeigniter custom routing issue
#1

[eluser]LoganPHP[/eluser]
This is my routes setup code

Code:
$route['general/(:any)'] = "videos/filter/$1/1";
$route['general/(:any)/(:num)'] = "videos/filter/$1/1/$2"; //pagination

Following link works fine.

Code:
www.example.com/general/latest
But below link doesn't work like what i want

Code:
www.example.com/general/latest-trending/5
$route['general/(:any)'] only executes always.

How to solve this issue?
#2

[eluser]PhilTem[/eluser]
Routes are executed in a first come first serve manner. That means your first route 'general/(:any)' will always be executed no matter if there is any number as third URI argument.

Change the ordering and it should be fixed!
#3

[eluser]CroNiX[/eluser]
In other words, the more specific routes (more segments) need to come before less specific routes (fewer segments), especially when using wildcards.




Theme © iAndrew 2016 - Forum software by © MyBB