default controller for sub folders |
[eluser]Jagar[/eluser]
My controller is as follow -Controllers -Admin home.php login.php -manage home.php .... I have set default controller as follow Code: $route['default_controller'] = 'home'; When I try www.sitename.net/index.php/admin does not work but when I do www.sitename.net/index.php/admin/home works My understanding was that even though I don't specify home it should load it home.php from the subfolder. Am i missing something? Thanks
[eluser]Aken[/eluser]
The default controller route is only for your homepage - when no URL segments are added, only www.example.com There is no assumed default for subfolders, so you'll need to either: A) Use routes to specify what file is the default for that folder. Code: $route['admin'] = 'admin/home'; B) Include a controller in your main folder that matches the folder name. Code: - controllers/
[eluser]PhilTem[/eluser]
I think CI Router will automatically look for an index-method if there is no second URI argument. However, I'm not sure what it does when the first uri-segment matches a folder. I guess it just prompts a 404 and does not look for a class called index with a method index. That's why there's the option to set a default controller for modules in HMVC. Because it is basically the same issue/problem ![]()
[eluser]Aken[/eluser]
As I said, there are no defaults set up for folders. I prefer to do the second option that I mentioned above, as it does not require routes.
[eluser]wiredesignz[/eluser]
[quote author="Aken" date="1352190264"]...There is no assumed default for subfolders, ...[/quote] @Aken, Maybe you should take a look at system/Router.php line 322 Code: // Does the default controller exist in the sub-folder? Judging by this code I'd suggest that CI does allow for the default controller to be located in a sub-directory.
[eluser]Aken[/eluser]
Damn, this one snuck by me! I've still been doing it the way I recommended here. Yeah, based on this and your original code, that should work. Make sure your directories are named properly, and that your controller name is actually just Home by itself. If you get any specific errors, that would help.
[eluser]wiredesignz[/eluser]
[quote author="Narf" date="1352283846"]This issue has already been fixed in the GitHub repo.[/quote] @Narf, Which 'repo' do you mean? I don't see any alteration to the 2.1 or master branches. What use is a fix in the 'develop' branch to people using the current release?
[eluser]Narf[/eluser]
There are no "current release fixes", fixes are done for the next version that is to be released. The next version is 3.0 and 3.0 code is in the 'develop' branch. |
Welcome Guest, Not a member yet? Register Sign In |