Home > Uncategorized > And permalinks are working (sort of)

And permalinks are working (sort of)

April 5th, 2009

The Apache mod_rewrite module provides a nifty little way to redirect URLs by rewriting them on the fly at the server level. Whip together a little regular expression to parse the incoming URL, construct a new destination URL for it, and presto — seamless transition. So, for example, an old link to the RSS feed like . . .

http://www.tenreasonswhy.com/weblog/atom.xml

. . . gets transformed on the fly to this . . .

http://www.tenreasonswhy.com/weblog/feed/atom/

. . . so I don’t think I’ll be breaking your feeds.

That’s all well and good when the incoming URL has the data you need. Unfortunately, Ten Reasons Why has gone through being originally hosted on Blogger’s blogspot.com way back in 2000, to being managed via Blogger but FTP’ed to an account on my at-the-time dial-up ISP Mindspring, to being hosted on tenreasonswhy.com through several different versions of Movable Type. And apparently, I wasn’t really very diligent about making sure the permalink approach was consistent among all of those changes.

A good number of the old posts in this blog have permalink URLs that, while based on the title of the entry, have been truncated in some fashion. For example, in some past version or configuration of Movable Type, the permalink URL for an entry titled “Wireless Saves The Day” became . . .

http://www.tenreasonswhy.com/weblog/archives/2003/12/wireless_saves.html

. . . but in WordPress that URL uses the full title, thus is:

http://www.tenreasonswhy.com/weblog/2003/12/wireless-saves-the-day/

. . . which is a fine and attractive URL, but finding a regular expression that will magically add those missing words is, well, impossible. Given only “wireless_saves.html” as the incoming location there’s no way to reconstruct “wireless-saves-the-day” out of that.

So, as a workaround, all of the old Movable Type permalinks (which are all distinguished by the “archives/” directory) now point to the monthly archive instead of to the individual entry. Therefore, the old MT permalink . . .

http://www.tenreasonswhy.com/weblog/archives/2003/12/wireless_saves.html

. . . will now automagically redirect to the archive page for the appropriate month here in WordPress-land:

http://www.tenreasonswhy.com/weblog/2003/12/

For the most part, that shouldn’t be a major problem for actual users, since, except for a few years between 2003 and 2006, when I was really active, few months have more than a handful of posts. It’s going to hork up my referrer stats, but you don’t really care about that, do you? :-)

And, in any event, that’s plenty of thinking about regex for a sunny spring afternoon. Off to the outdoors!

Greg Uncategorized , ,

  1. No comments yet.
  1. No trackbacks yet.