Is there a way to route an entire controller? |
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.
Rewrite in .htaccess:
RewriteRule ^debate$ /main/debate [L] Or just use CI routing. (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';
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. (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 (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. |
Welcome Guest, Not a member yet? Register Sign In |