If you are working on CodeIgniter Project and want to customize the pages URLs. Codeigniter offers you to do this by using it Routing function. The Routing the is method for hiding the controller and model functions from your url.
Lets get started Routing in Codeigniter.
Step 1: Open the file routes.php. You can find this file at location Application-> Config->Routes.php
Create a new route in this file which will go like this:-
$route['myplace'] = 'User/myplace';
In the code line above the User is your controller and myplace will be the function inside it. So if you have a place link target to this url then after making the route you just need to write
You will notice that instead of writing full url of Controller and Function you can just replace it with a single word. Both the link will open the same url but the new url will be more user and SEO friendly.
Now lets say if you have any variable in the url segment then there is an another syntax that you need to specify.
For example if your dynamic url is
Now here 3rd url is dynamically generated which is an int type. So for this type of url you need to create the route like this:-
$route['city_id/:num'] = 'User/city_id';
Similarly for multiple variables you can mention ( :num )multiple times and it will go like this:-