• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
$route['(:any)/(:any)'] and $route['(:any)'] problem when using together

#1
[eluser]Nexima[/eluser]
Hi all,

I am using like this

Code:
$route['tur/(:any)'] = "tur/index/$1";
$route['(:any)/(:any)'] = "yazilar/index/$1/$2";

but they conflict with themself. I tried a lots of combination also I added someting over htaccess but I coulnd't.

how can I correct?

Regards

#2
[eluser]DarkManX[/eluser]
well, ci will use the first matching route and use it. your stuff should work fine in this given order

#3
[eluser]Nexima[/eluser]
Thank you for fast reply DarkManX.

I had a mistake when i am copying codes.
these are actual codes.
Code:
$route['(:any)'] = "tur/index/$1";
$route['(:any)/(:any)'] = "yazilar/index/$1/$2";

when I want to access second one I redirected first one.

#4
[eluser]CroNiX[/eluser]
You need to reverse those so that the more specific route (with 2 segments) comes before the one with one. Otherwise, it will always match the first route because of the (:any) in the first segment, regardless of any extra segments that are present in the request.

#5
[eluser]Nexima[/eluser]

I reversed lines but this time first one is blocking second one again.




#6
[eluser]CroNiX[/eluser]
Ah, yes. You can't have 2 rules that start with (:any) because both will match everything. It would work the way you originally had it, with one starting with (:any) and the other starting with "tur/".

#7
[eluser]Nexima[/eluser]
Thank you for your interest. I'll use like on first post. already "/tur" is not so important for seo degree. it was only for categories. I am going to try this over .htaccess file. If I can do from htaccess.I'll share from here.



Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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