Today we are going to discuss about routing in codeigniter. Routing is the process of identifying controller and the method as per the http request. when a url is being given codeigniter routing mechanism will determine which page is to be responded to that request. For that codeigniter has various methods. By default they will provide routing as follows
so this will automatically pointed to controller called student. And the method called display will be invoked and the argument will passed to the function as rahul.
This is the default routing machanism of codeigniter. But programmer can change this scenario. A programmer can determine which controller is being invoked on which request. this can be done by editing the route file on application configuration.
that file contains a statement like this
$route['default_controller'] = "student";
which determines the default controller. now student is the default controller. So if you are not mention any controller then student will be your controller.
You can also apply regular expressions in the simplest way (:any) is the expression we can use as reqular expression
$route['(:any)'] = 'student/display/$1';
The statement above means when ever a request appears it will be mapped to student/display/(expression)
so if the request is
will be pointed to