![]() |
User routing - 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: User routing (/showthread.php?tid=8961) |
User routing - El Forum - 06-06-2008 [eluser]Nial[/eluser] I have the following route rule: Code: $route['user/:any'] = "user/view"; Which makes domain.com/user/username possible. However, I'd like to be able to do: domain.com/user/username/rss, for example. Where rss is a method within the user controller (just as view is). How can I accomplish this? User routing - El Forum - 06-06-2008 [eluser]m4rw3r[/eluser] add: $route['user/:any/rss'] = 'user/rss'; above the user/:any rule, I think User routing - El Forum - 06-06-2008 [eluser]marcoss[/eluser] In the first place, and from an design perspective, it would be better to use domain.com/rss/username instead, otherwise, when your app grows, routing will get really complex, you will have to deal with domain.com/user/username/photos, domain.com/user/username/notes, domain.com/user/username/blog, all in the same controller, instead of photos/username, notes/username, blogs/username. Anyway, if you still want to go with that design, you should avoid the routes option and use the _remap() function inside your controller, there you can intercept the request before the default method gets called and route it based on the username and "action" requested. |