Create a custom controller function link in codeigniter

To create a custom URL link for the a specific function in the codeigniter we configure it in the routes.php file. The routes.php is located in config folder config/routes.php.

Source code to set the custom routes in Codeigniter

<?php $route['Login'] ='Auth/Login'; ?>

Now you can load 'Base-url/Auth/Login' using 'Base-url/Login'.

Accept function parameters

To accept the parameter in custom routes we use the parameter type the * accept all data types.

Playvideo($video_id) //Actual function in Dashboard Controller <?php $route['PlayVideo/(*!)'] ='Dashboard/Playvideo/$1'; ?>
Chapter Next »