|
|||
|
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"
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:
Any thoughts anyone? Thanks |
|
|||
|
Instead of multiple routing rules, you can probably handle use a more advanced regex. Making the different sections optional. Something like:
Code:
archive/(?:([12][0-9]{3})(?:_([^_]+)(?:_([0-9]{1,2}))?)?)?$
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|