CodeIgniter Forums

Full Version: Routes problem
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[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

El Forum

[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

El Forum

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

El Forum

[eluser]yello[/eluser]
Works!

Inversed the two rules Smile