WordPress calendar link problem/fix

This is a 1.0 bug report, so it may have been fixed in 1.0.1. Here’s the deal. One of the side effects of Worpress feeding everything out of MySQL is that everything has a native url of index.php?[something-or-other].

This sounds harmless, but when Google and it’s ilk come to crawl your site, it looks like there is only one page, index.php. This spider indexes your welcome page and goes on its way, and no-one will ever find any of the wonderful content on your site.

The smart folks at WordPress know this, and have set up a method to make it look like you have all your content out in static pages, so spiders will find it. The method uses mod_rewrite, which does regular expression search/replaces on URLs. (Note, this is fairly deep magic. if you don’t know what a regex is, treat this all as voodoo.) The concept is quite spiffy, and there’s code in the admin section to make it easy. You tell it what you want your URLs to look like and WordPress tells you the incantations to give to Apache.

Unfortunately the incantations don’t work on the URLs that come out of the little built-in calendar thingie. Hereinbelow is an incantation that will.

Anyway, I set my options -> permalinks to %year%/%monthnum%/%day%, and go told that I should use some cockamamy mod_rewrite rule that spat out year=$1&monthnum=$2&day=$3.
Unfortunately Wodpress didn’t think this meant what it said. I kept getting various posts from May of 2003. A given link would always get the same post, but no link fetched a post that wasn’t from May of 2003.

I finally got tired of diddling with it, read the README file and put in my own mod rewrite rule:

^archives/([0-9]{4})?/?([0-9]{1,2})?/?([0-9]{1,2})?/? index.php?m=$1$2$3

it works like a champ.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.