• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
URI Routing not working properly

#1
[eluser]Emkay[/eluser]
I am using the following routing rules

Code:
$route['(:any)-(:num)'] = "category/$2";
$route['(:any)-(:num)/(:any)-(:num)'] = "listing/$4";

While the first one works just fine, the second rule does not.

For example,

Code:
www.website.com/books-5/
works, while

Code:
www.website.com/books-5/Engineering-Thermodynamics-102451

does not. It just leads me to a not found error, when in fact the rerouting url would be valid if it was routing correctly.

Can anyone pinpoint the problem?

#2
[eluser]Rok Biderman[/eluser]
You should change the order of the routes, so that the more specific is the first. This way you're always executing the first one, 'cause everything that would satisfy the second condition also satisfies the first.

#3
[eluser]Emkay[/eluser]
I didn't think it would be that simple Tongue Thanks a lot, it worked Big Grin

#4
[eluser]jerry01[/eluser]
thanks, great tip


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.