is there any way to remove or hide the controller name in url? codeigniter is there any way to remove or hide the controller name in url? codeigniter codeigniter codeigniter

is there any way to remove or hide the controller name in url? codeigniter


You can do this using $route.

If you have only one Controller and in that controller you all the functions you can write something like this:

$route['(:any)'] = "Controller_Name/$1";

If you have many Controllers you need to specify for each function to what controller to point. Like this:

$route['function1'] = "Controller_Name1/function1";$route['function2'] = "Controller_Name1/function2";$route['function3'] = "Controller_Name3/function3";

And you can't have duplicates in $route

This $route array should be located here: application/config/routes.php.

You can check more about routes on the CI documentation here: https://www.codeigniter.com/userguide3/general/routing.html


You have to specify your controller and method name in routes file like below

$route['function_name'] = 'controller_name/function_name';

You have to write this for each function in controller.By doing you get two advantages

1) Controller name will be hidden in your url2) you can call some method by its name only.No need to use controller name every time.