Welcome Guest, Not a member yet? Register   Sign In
Routes order
#1
Rainbow 

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! Big Grin
Reply
#2

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.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB