Can I Route YYYY/MM/DD URL Segments to a Controller? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Can I Route YYYY/MM/DD URL Segments to a Controller? (/showthread.php?tid=40650) |
Can I Route YYYY/MM/DD URL Segments to a Controller? - El Forum - 04-14-2011 [eluser]kirkaracha[/eluser] I'm trying to use routes to have a timeline controller handle URLs like this: example.com/2011/04/15 I tried these routes, but they aren't working (I get a 404): Code: $route['(:num)/(:num)/(:num)'] = 'timeline/$1/$2/$3'; // year, month, and day What am I missing? Can I Route YYYY/MM/DD URL Segments to a Controller? - El Forum - 04-14-2011 [eluser]guidorossi[/eluser] I think that's because the "2011" function doesn't exists under the timeline controller... It should be: Code: $route['(:num)/(:num)/(:num)'] = 'timeline/foo/$1/$2/$3'; // year, month, and day and the controller like: Code: class Timeline extends CI_Controller { Can I Route YYYY/MM/DD URL Segments to a Controller? - El Forum - 04-14-2011 [eluser]kirkaracha[/eluser] This worked, thanks! Routes: Code: $route['(:num)/(:num)/(:num)'] = 'timeline/day/$1/$2/$3'; Controller: Code: public function year() { |