I want to implement SEO URLs in my application, of the type:
http://www.mysite.com/archive/2008_apr_5
This is easy to do using a regex route, EG:
Code:
routes.archive.type = "Zend_Controller_Router_Route_Regex"
routes.archive.route = "archive/([1|2][0-9]{3})_([^_]+)_([0-9]{,2})"
routes.archive.reverse = "archive/%d_%s_%d"
routes.archive.defaults.module = "archive"
routes.archive.defaults.controller = "index"
routes.archive.defaults.action = "index"
routes.archive.map.1 = "year"
routes.archive.map.2 = "month"
routes.archive.map.3 = "day"
The catch is I want the number of parameters to change, that is, all this links will go to the same controller and same action but with a different set of request parameters:
http://www.mysite.com/archive/2008_apr_5
http://www.mysite.com/archive/2008_may
http://www.mysite.com/archive/2007
http://www.mysite.com/archive/
So the question is, what is the best way to achieve this. I can think of 2 options:
- Have multiple regex routes, one for each parameters count, each having a different name
- Write my own custom 'multi-regex' route which knows how to handle these options
None of these options are perfect though...
Any thoughts anyone?
Thanks