URI routing problem - $route['listings/(:any)'] - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: URI routing problem - $route['listings/(:any)'] (/showthread.php?tid=50480) |
URI routing problem - $route['listings/(:any)'] - El Forum - 03-27-2012 [eluser]Brad Martin[/eluser] Hi Guys, Got a problem with the URI routing in ./config/routes.php I want to have the following routes: $route['listings/(:any)'] = 'listings/index/$1'; // example url: listings/some-text $route['listings/(:any)/(:any)'] = 'listings/profile/$2'; // example url: listings/some-text/some-more-text It seems like the first route is overriding the secondary route because of the use of (:any) I tried any alteration of: $route['listings/(:num)'] = 'listings/index/$1'; // example url: listings/1 $route['listings/(:num)/(:num)'] = 'listings/profile/$2'; // example url: listings/2/3 And this seems to work but i need them to be text not numbers. I know i can overcome this issue by remaping in the controller but i was looking for a simpler way. Is this a bug in code igniter ? Is there any other options i can use for overcoming this which out having to remap the controller. URI routing problem - $route['listings/(:any)'] - El Forum - 03-28-2012 [eluser]CodeIgniteMe[/eluser] change the order of the routes place $route[‘listings/(:any)/(:any)’] = ‘listings/profile/$2’; before $route[‘listings/(:any)’] = ‘listings/index/$1’; URI routing problem - $route['listings/(:any)'] - El Forum - 03-28-2012 [eluser]Brad Martin[/eluser] Worked perfectly! Thanks URI routing problem - $route['listings/(:any)'] - El Forum - 03-28-2012 [eluser]CodeIgniteMe[/eluser] Welcome, just put the child route before it's parent route so the route will not be overriden |