A thought inspired by this message on the wp-hackers mailing list by Mike Purvis, and The Cathedral and The Bazaar by Eric S. Raymond, a few chapters of which I read recently for the first time. Lesson 9 sprang to mind. Then this did. An old defeat.

<div markdown=”1″>
- /articles|posts|entries/ (literal text)
- – /[12][90][09][0-9]/ (year number, almost – allows 1000, intended to be 1990-2099)
- – – /01|02|03|04|05|06|07|08|09|10|11|12/ (month number)
- – – – /[0-3][0-9]/ (day number, almost – allows 00 and 39)
- – – – – %postname% (content meta-data expression – the name of a post)
- – – /[0-3][0-9][0-9]/ (day of year, almost – allows 000 and 399)
- – %postname% (not at root, so match postname and continue to endpoint expression)
- /article|post|entry/
- – %postnumber% (post number, canonical in this content, would conflict with year in /articles/ hierarchy)
- – ../articles (for convenience, reference entire tree that matches articles, post number takes precedence over year)
- %postname% (endpoint expression, if you want postname to match at root, specify /%postname%/)
- – all the endpoints possible for a postname
- – ?next (functional endpoint – allows either “?next” or “/next” to be specified after a postname, redirect to next post by default navigational dimension)
- – ?prev
- %postnumber%
- – ../%postname% (what you can do with a postname you can also do with a post number)
- – ?next
- – ?prev
- /cat(egor(y|ies))?/
- – %categoryname%
- – %categorynumber%
- /%categoryname%/ (match category name at root)
- %categoryname%
- – ../%categoryname% (oh my! dive down the category hierarchy?)

Explode incoming request path on slash. Many routes forward from each node: 0 (is your endpoint, contains translation code) or 1+ (is not your endpoint, array of associative keys as regular expressions to match at each level.

</div>

Leave a Reply

You must be logged in to post a comment.