![]() |
Routing Help Needed - 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: Routing Help Needed (/showthread.php?tid=66760) |
Routing Help Needed - codeigniterd - 11-28-2016 My URL now showing like this.. for a blog post example.com/blog/view/new-blog-post how can i make it look like this.. example.com/blog/YYYY/MM/DD/new-blog-post Thanks in advance ? Actually i am little wondered how developer achieve this in blog post. RE: Routing Help Needed - Martin7483 - 11-29-2016 First, I would not use this date format (YYYY/MM/DD) in an URL. That format would result in 5 URI segments being set. Use YYYY-MM-DD instead. That will leave you with 3 segments. If you have a controller named Blog, add the _remap method. Check out the documentation on that. _remap documentation In short, the second segment in your URL will be passed as an argument, and you can then check it, and remap it to any method within your controller. If your index method shows a list of all your blogs you could have a method get_blog($date, $blog_title) for getting that specific blog entry. PHP Code: public function _remap($method) { Hope this gets you on your way - Martin RE: Routing Help Needed - codeigniterd - 11-29-2016 thanks |