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

Hi all,

I am using like this

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


well, ci will use the first matching route and use it. your stuff should work fine in this given order

Thank you for fast reply DarkManX.

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

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

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.


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

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/".

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.