![]() |
Routes order - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Routes order (/showthread.php?tid=63054) |
Routes order - Gareehc - 09-21-2015 Im just learning about codeigniter and am stumped by the following: I have these routes in my routes file: $route['(:any)'] = 'pages/view'; $route['news/create'] = 'news/create'; $route['news/(:any)'] = 'news/view/$1'; $route['news'] = 'news'; $route['default_controller'] = 'pages/view'; Yet when I load "http://localhost:8888/clinicases/index.php/news," it loads the news page rather than 'pages/view,' i thought that because i have the catchall route at the top, this page would also just load pages/views. Where am i going wrong? Thanks! ![]() RE: Routes order - mwhitney - 09-21-2015 The router checks for a match before it attempts to process any wildcard routes. So, with the routes you've defined, more than likely you'll see a different result for http://localhost:8888/clinicases/index.php/news/index than for http://localhost:8888/clinicases/index.php/news, since http://localhost:8888/clinicases/index.php/news will match $route['news'], no matter where it is in the config/routes.php file, while http://localhost:8888/clinicases/index.php/news/index will match either $route['(:any)'] or $route['news/(:any)'], depending on the order of the items in the config/routes.php file. |