• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Routes problem

#1
[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

#2
[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

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

#4
[eluser]yello[/eluser]
Works!

Inversed the two rules Smile


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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