By default, CodeIgniter routes URLs to the class (first URL segment) and method (second URL segment) specified in the URL string. For example, "" would be routed to the "about" method within the "home" controller class. If a method is not specified in the URL string, the default method is executed within the specified controller class. However, in some situations you may need to dynamically route certain URL strings to different classes or methods within your application, and CodeIgniter allows you to do this in a very simple way.

So in my example, I want to route "" to a method within a different controller, because the "r" controller does not exist in my application. To change the route, I need to go to the application/config folder and open "routes.php". At the bottom of this file notice "RESERVED ROUTES" and in my case I need to add the following line:

PHP Code:
$route['r/(:any)'] = '/home/r/'
This would route anything starting with "r" in the URL string (such as "", "" etc.) to the r() method within the home controller.