dynamic 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: dynamic routing (/showthread.php?tid=50989) |
dynamic routing - El Forum - 04-16-2012 [eluser]brian88[/eluser] I have 3 controllers main, login, cms heres my routes, it doesnt work. Code: $route['(:any)'] = "main/$1"; I just want mysite.com/page not mysite.com/cms/page Whats the best way of achieving this? Because my way obviously doesnt work dynamic routing - El Forum - 04-17-2012 [eluser]PhilTem[/eluser] It doesn't work because routing works with "first come first serve" i.e. the first matched route will be used. You'd have to make something like a bootstrap-router, which will process your requests any further with this route Code: $route['(:any)'] = "router/bootstrap/$1"; This way your router-controller and bootstrap-method will be called with the whole URI-string as arguments. You can then do your processing of requests by checking e.g. the first URI-segment and including the appropriate file. dynamic routing - El Forum - 04-17-2012 [eluser]Reneesh T K[/eluser] If there is a third parameter except class name and function name, I faced some problem when routing and I fixed it using the following tutorial http://myphplibrary.blogspot.in/2012/03/codeigniter-routing-issue-fixation-url.html dynamic routing - El Forum - 04-20-2012 [eluser]brian88[/eluser] How do I do this bootstrap way exactly? dynamic routing - El Forum - 04-23-2012 [eluser]brian88[/eluser] is there a library for this "router" controller and "bootstrap" method? Because this seems like a common thing to do. How does this logic work? |