问题
For the following application directory structure under / in Kohana 3:
application
- classes
- controller
- controller1.php
modules
- admin
- classes
- controller
- controller2.php
And the urls be: /controller1 and /admin/controller2?
I seem to be missing something though because I keep getting a 404 error with the /admin/controller. What am I doing incorrectly?
The exact error is:
HTTP_Exception_404 [ 404 ]: The requested URL admin/borrowers was not found on this server.
And I don't have any custom routes setup. This is a very vanilla K3 install at this point.
回答1:
The directory structure seems to be a little of.
Using a module doesn't automatically means you have a subdirectory. The default route defines the following url structure:
/[controller]/[action]
So for the directory structure that you have given, you get the following:
/controller2/
The action can be left out, but it will default to index
.
If you want a special admin subdirectory, you would first have to create that subdirectory in you modules classes directory like this:
/admin/classes/admin/controller2.php
Then you would have to add another route that handles the subdirectory. You can find more information about that in the userguide
来源:https://stackoverflow.com/questions/5444286/how-to-use-module-controllers-in-kohana-3