View Source

<ac:macro ac:name="unmigrated-inline-wiki-markup"><ac:plain-text-body><![CDATA[{zone-template-instance:ZFDEV:Zend Proposal Zone Template}

Additional features

[My E-mail Address|]

1.1 - 1 August 2006: Updated from community comments.

I'm writing this page to propose some additional feature to the Zend Framework.
Maybe it will be useful to manage all URLs in the website and transform them in SEO friendly urls, or simply to have a powerful sistem that doesn't permit non existent urls... Or also, the possibility of automatically filter urls with Zend_Filter.



I want to have control on all website's urls.
* this component *will* filter url (or just some parameters) with Zend_Filter or custom Filters (strtolower on all url or just on some parts of it) EX:$NICKNAME/ --> I want the NICKNAME in lower case...
So, if I assemble the url with $NICKNAME = 'Prova', the resulting url must be htt:// and NOT
* this component *will* check if the REQUEST URI is semantically correct. If not, it will do a 301 redirect to the right url
EX: (with filter strtolower on parameter NICKNAME) must automatically redirect to
* this component *will* "sanitize" urls (no url likeurl.php?without parameters... orurl.php?r=&with empty parameters...)
EX: --> must be without question mark like end character of the url string.
* this component *will* give the possibility to "deduplicate" parameters...
EX: --> par1 is declared 2 times!!! must return

* Zend_Config
* Zend_Controller_Router
* Zend_Filter
* Zend_Controller_Action_Helper_Url

I'm not writing about a single component. I think the best choice to manage urls is to use:
* Zend_Config & Zend_Filter together in xml or ini files (so you can have custom configuration foreach rewrite rule)

* Zend_Controller_Router must check the assembled url is equal to the request uri. If not, perform a redirect to the correct url
* Zend_Filter_SeoUrl (as proposed byMartin Hujerhere: must give the possibility Zend_Controller_Action_Helper_Url->url() return always semantically correct urls.

I write some code of example here:

1) --> NICKNAME in lower case letters:
CONFIG file for routing:
routes.homeuser.type = "Zend_Controller_Router_Route_Regex"
routes.homeuser.route = "([a-z0-9]+)/*"
routes.homeuser.defaults.module = "user"
routes.homeuser.defaults.controller = "index"
routes.homeuser.defaults.action = "index" = "nick"
routes.homeuser.reverse = "%s/"
*routes.homeuser.filter.nick = "Zend_Filter_StringToLower"*
; or also *routes.homeuser.filter.ALLURL* = "Zend_Filter_StringToLower" if I want to filter the complete url

When I call Zend_Controller_Action_Helper_Url->url(array('nick' => 'Prova'), 'homeuser'), the function must recognize there is a filter on "nick" and apply it to give me back the correct url: AND NOT

2) Check the request uri is right:
After enter the routeShutdown, I have the possibility to check if the request uri is equal to the url I can assemble with same parameters...
EX: request uri =
routeName = homeuser
nick = Prova

I try to assemble the url with Zend_Controller_Action_Helper_Url->url(array('nick' => 'Prova'), 'homeuser').
The result is (different from !!! So I must do a 301 redirect to

This can be done with a Plugin that use the routeShutdown() Action, or after the router evaluates the request.