Reputation: 3280
In my application I am currently using the standard parameter passing, for example http://localhost/api/shops/deals/$shop_id
But i need the urls to be like http://localhost/api/shops/$shop_id/deals
How can I achieve that?
Upvotes: 1
Views: 635
Reputation: 5398
Use application/config/routes.php
file to do that. Like
$route['api/shops/(:num)/deals'] = 'api/shops/deals/$1';
Now when your URL will be http://localhost/api/shops/3/deals
then it will execute as http://localhost/api/shops/deals/3
for more details https://codeigniter.com/user_guide/general/routing.html
Upvotes: 4