![]() |
how to make shorten url in codeigniter - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: how to make shorten url in codeigniter (/showthread.php?tid=70104) |
how to make shorten url in codeigniter - hamid - 02-21-2018 Suppose my site has a get request with below URL. http://localhost/mysitename/MainController/Testmethod?areaname=abc But I want to alias the URL in shot form as like: http://localhost/mysitename/Testmethod How can I make the short form URL using alias ? RE: how to make shorten url in codeigniter - albertleao - 02-21-2018 If you're trying to pass data using URL query params, you have to put them in the url query params. You can also pass data through post requests but that would mean your user has to submit a form. If you're looking to have 'clean' urls, you may want to look at a RESTful styled urls: http://www.restapitutorial.com/lessons/restfulresourcenaming.html RE: how to make shorten url in codeigniter - hamid - 02-21-2018 (02-21-2018, 10:27 AM)albertleao Wrote: If you're trying to pass data using URL query params, you have to put them in the url query params. You can also pass data through post requests but that would mean your user has to submit a form. If you're looking to have 'clean' urls, you may want to look at a RESTful styled urls: Thanks albertleao for your valuable suggestion. But I have one question here..if I want to pass more than one data through query params then how I can use RESTful styled urls ? RE: how to make shorten url in codeigniter - ciadmin - 02-21-2018 You can use routing ... $routes['mysitename/testmethod'] = 'maintroller/testmethod'; See https://www.codeigniter.com/user_guide/general/routing.html#setting-your-own-routing-rules RE: how to make shorten url in codeigniter - albertleao - 02-21-2018 Using routing like ciadmin mentioned above you can do something like this: mywebsite.com/users/123/posts/123 Then in your routes file you do this: PHP Code: $route['users/(:num)/posts(:num)'] = 'posts_controller/show/$1/$2'; and in your posts controller PHP Code: class Posts_controller extends CI_Controller { RE: how to make shorten url in codeigniter - hamid - 03-22-2018 Thanks all for your valuable suggestions. I was out of internet for last few days and I was late to reply. Apologize for this. |