Labels
Zend Framework: Zend_Controller_Front in Subdirectory Proposal Component Proposal
| Proposed Component Name | Zend_Controller_Front in Subdirectory Proposal |
|---|---|
| Developer Notes | http://framework.zend.com/wiki/display/ZFDEV/Zend_Controller_Front in Subdirectory Proposal |
| Proposers | Christopher Thompson |
| Revision | 1.1 - 1 August 2006: Updated from community comments. (wiki revision: 9) |
Table of Contents
1. Overview
Allow the Front Controller to be placed in a sub-directory and work with different URL styles.
2. References
3. Component Requirements, Constraints, and Acceptance Criteria
- Front Controller to be placed in a sub-directory
- Allow different URL styles
4. Dependencies on Other Framework Components
5. Theory of Operation
This change inspects the URL and removes the base part of the URL to provide a clean PATH_INFO portion to the Router/RewriteRouter. The change is the same for either Router class.
6. Milestones / Tasks
7. Class Index
8. Use Cases
Allows URLs like the following:
www.mydomain.com/mycontroller/myaction/
www.mydomain.com/index.php/mycontroller/myaction/
www.mydomain.com/sub/dir/mycontroller/myaction/
www.mydomain.com/sub/dir/index.php/mycontroller/myaction/
An enhancements would be to allow routing based on parameters as well, such as:
index.php?controller=mycontroller&action=myaction
9. Class Skeletons
I have and have applied the patch to the new RewriteRouter class as well (they are identical in this respect). As I said they are the same. I don't know the answer to your question. Nor do I know the thinking of those working on this. I proposed this as a possible solution early on and have not seen changes that address the problem. There are several way to potentially solve this.
I understand that the new RewriteRouter allows you to define routes, but I do not believe that it deals with the Front Controller being in a sub-directory. I see that they have added a "base url" to the RewriteRouter which may be a different solution to the same problem – I don't know and it would need to be set manually.
The problem as I showed above is that if you put the Front Controller in a sub-directory and geive it the URL:
www.mydomain.com/sub/dir/mycontroller/myaction/
The router take the route to be "/sub/dir/mycontroller/myaction/" and converts it to the equivalent of:
controller=sub&action=dir&mycontroller=myaction
I think you need to take another look at RewriteRouter. You can easily add routes under subdirectories. Currently, you must include the subdirectory in the route, but I'm trying to talk Martel into automatically prepending _rewriteBase.
With current version of RewriteRouter you can use it within subdirectories. RewriteBase is also detected automatically so you don't need to set anything by hand.
Thank you all.
Given the RewriteRouter handles subdirectories, I suspect that we should concentrate on working out the correct RewriteBase in as many webserver configs as possible.
I would prefer that the calculation of RewriteBase should be done in the request object really and then use RewriteRouter's SetRewriteBase() as proposed in http://framework.zend.com/wiki/x/eB.
ZF Home Page
Code Browser
Wiki Dashboard
Have you looked at the new Rerouter class? It already hanldes this by allowing the developer to define the paths