URL routing in PHP Codeigniter URL routing in PHP Codeigniter codeigniter codeigniter

URL routing in PHP Codeigniter


Try this code it might help you :

Here dashboard is the name of controller

//this will route as localhost/appFolder/admin/index  $route['admin'] = 'dashboard'; // for your index page//this will route as localhost/appFolder/admin/method_name $route['admin/(:any)'] = 'dashboard/$1';//this will route as localhost/appFolder/admin/method_name/param1$route['admin/(:any)/(:any)'] = 'dashboard/$1/$2';

Link the route Like

// for your index page<a href="<?php echo base_url('admin/index'); ?>"></a>// for your other pages<a href="<?php echo base_url('admin/method_name'); ?>"></a>

To link the other controller defined just like

 <a href="<?php echo base_url('otherControllerName/method_name'); ?>"></a>


school is your ci root, so if you define $route['/school/admin/students'], it will seek school class with admin function, that never exist, instead of admin route.

you should read the documentations first before make any step, https://www.codeigniter.com/userguide3/general/routing.html