CodeIgniter Forums
Routes problem - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Routes problem (/thread-3680.html)



Routes problem - El Forum - 10-16-2007

[eluser]yello[/eluser]
config/routes.php
Code:
$route['browse/:any'] = "main/browse";
$route['browse/:any/:any'] = "main/browse_state";

Only $route['browse/:any'] = "main/browse"; works. Why isn't the other one working properly?

Thanks


Routes problem - El Forum - 10-16-2007

[eluser]crikey[/eluser]
Routes are run in the order they are defined (according to the Routes section of the manual).

Because your first route rule already covers the second one (that is, the first rule will be applied when *any* characters follow 'browse/'), the first rule is applied and the second rule isn't tested. Try swapping the order?

Note: I haven't tried it, but it looks like that's how it works.

Cheers


Routes problem - El Forum - 10-16-2007

[eluser]Armchair Samurai[/eluser]
Routes are processed in order and earlier routes will take presidence - try reversing the positions in the $route array.


Routes problem - El Forum - 10-16-2007

[eluser]yello[/eluser]
Works!

Inversed the two rules Smile