default controller in sub folder |
In Tutorial/Create news items/Routing section I see $route['default_controller'] = 'pages/view' line. This means we can assign controller in a subfolder as default controller. But I get 404 Page Not Found error when I assign 'website/home' (Home.php controller file in website directory) as default controller. Any idea?
No, it means you can also include the method in there as well. Syntax is 'controller/method'.
This what i do
$route['setting'] = "m_admin/setting/sidebar"; m_admin is folder name, Settings is controller name and sidebar is function name
@Narf 1- It is working in CI 2.2 (folder/controller).
2- In CI 3.0 ChangeLog Core/Routing section it says - Added support for per-directory default_controller and 404_override classes. 3- In Bug Fixes section - Fixed a bug - :doc:`Routing Library <general/routing>` didn't properly handle default_controller in a subdirectory when a method is also specified. I think here is a bug or backward incompatibility. (11-06-2014, 06:58 PM)bobykurniawan Wrote: This what i do That is what you've done in CI2, you are in the "CodeIgniter 3.x" forum. (11-06-2014, 08:38 PM)obozdag Wrote: @Narf 1- It is working in CI 2.2 (folder/controller). 1. Yes, I know it's "working" in CI 2.2. 2. Yes, and it works in a completely different way. 3. Yes, this bug is what has allowed you to say 1. It was a bug that you were able to do that.
2- That means
I can assign default controllers for http://website.com/admin (admin is a subfolder in controllers folder) or http://website.com/public (public is a subfolder in controllers folder) but I can't assign default controller for http://website.com. It is possible to have default controllers for subfolders but impossible for root. It seems unreasonable.
Funny - I was asked this question privately a few hours ago
This is what I determined... With CI3, if you have defined your default controller to be "whatever", then the router will look for that controller inside any URI which is in fact a sub-sub-sub...directory inside application/controllers. /my/wonderful/web/stuff would be resolved by application/controllers/my/wonderful/web/stuff/Whatever->index() using the above. It could also be resolved by application/controllers/my/wonderful/Web->stuff(). Or it could be resolved by application/controllers/my/Wonderful->web('stuff') Or by application/controllers/My->wonderful('web','stuff') Oh my! Can this be right? AM I stuck in a loop? Dig into the code and check it out! ps A matching custom route, in config/routes.php, would override the above. (11-07-2014, 12:54 AM)obozdag Wrote: 2- That means No, it doesn't mean that. As I said - it works in a completely different way. https://github.com/bcit-ci/CodeIgniter/issues/2849 |
Welcome Guest, Not a member yet? Register Sign In |