Is there a way to route an entire controller? - 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: Is there a way to route an entire controller? (/showthread.php?tid=68590) |
Is there a way to route an entire controller? - desbest - 08-01-2017 Is there a way to route an entire controller, so I can route a controller to be / (root directory)? Let's say my controller looks like this. Code: <?php By doing this (setting a route for my controller), all actions in my specific controller I set the controller's route in, (such as "debate") inherit this route so action debate has the /debate url and action question has the /question url. It would be more convenient to map or route an entire controller and all actions in that controller by default become a subroute of it, than setting each route for each of my controller actions individually. RE: Is there a way to route an entire controller? - skunkbad - 08-01-2017 Rewrite in .htaccess: RewriteRule ^debate$ /main/debate [L] Or just use CI routing. RE: Is there a way to route an entire controller? - desbest - 08-07-2017 (08-01-2017, 10:46 AM)skunkbad Wrote: Rewrite in .htaccess: Yes but I want to route the entire controller, not each method individually. How do I do that? RE: Is there a way to route an entire controller? - skunkbad - 08-07-2017 (08-07-2017, 01:29 PM)desbest Wrote:(08-01-2017, 10:46 AM)skunkbad Wrote: Rewrite in .htaccess: It's not possible. You may be able to come up with a RewriteRule or CI routing that uses a regular expression, but there is no magic way to do what you want to do. A CI route like this might work: PHP Code: $route['(debate|question)'] = 'main/$1'; RE: Is there a way to route an entire controller? - John_Betong - 08-07-2017 A Kludge I use is to route any unfound URIs to a search routine. A search of an exact match for a table url_title() matching the URL or a nearest match or the table unique record number calls the relevant matching table record. If the above fails the standard 404 is called. RE: Is there a way to route an entire controller? - desbest - 08-08-2017 I am going to request this feature in the next version of Codeigniter. RE: Is there a way to route an entire controller? - jonathanq - 08-10-2017 (08-08-2017, 12:34 AM)desbest Wrote: I am going to request this feature in the next version of Codeigniter. What do you think about Routes in a Controller Comments RE: Is there a way to route an entire controller? - desbest - 08-11-2017 (08-10-2017, 08:47 AM)jonathanq Wrote:(08-08-2017, 12:34 AM)desbest Wrote: I am going to request this feature in the next version of Codeigniter. I don't think that is helpful. |