CodeIgniter Forums
URI Routing not working properly - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: URI Routing not working properly (/showthread.php?tid=43698)



URI Routing not working properly - El Forum - 07-20-2011

[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?


URI Routing not working properly - El Forum - 07-20-2011

[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.


URI Routing not working properly - El Forum - 07-20-2011

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


URI Routing not working properly - El Forum - 07-20-2011

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