Mapping The Past

Though I’ve converted the site over to WordPress, the old Movable Type archives are still there and accessible. This presents a bit of a problem, because how do I get rid of them? Search engines are going to continue referring to them for a while, so it would make sense to leave them in place so the searcher doesn’t get a 404, but leaving them there will just keep them in the search engines even longer. Redirecting all requests that point at the old archives to the new main page would be unfriendly, since it wouldn’t be what they were looking for.

What would be preferable is to have requests to the old pages automatically redirect to the same article under the new site. The major problem there though, is that the article numbers under the two systems are not the same; what was article #77 under MT is now #74 under WordPress, for example. It’s not a simple single offset for all the articles either, since MT exported them in the order they were posted, not by numerical order.

So, clearly what’s needed is some kind of script that will map the old numbers to the new numbers. Figuring that PHP might be worth a look, since WordPress itself is implemented in it, I brought up the PHP Manual, opened some of the WordPress code in an editor as a sample, and hacked out the following: redirect-mt.php

Instead of mapping each and every article number, it takes advantage of the fact that large ranges of numbers have the same offsets, so all it has to keep track of is the boundaries of those ranges. It took longer than I thought it would to extract those ranges from the MT articles, but the generation of that list could be automated, too. I was just lazy.

This script will remap the article numbers, but I still have to capture the requests and feed them to this script. Fortunately that’s a fairly simple addition to the .htaccess:

# Redirect Movable Type archive requests to the WordPress articles,
# through a remapper script
RewriteRule ^archives/([0-9]{6}).html$ /heide/redirect-mt.php?index=$1 [QSA]

It seems to work well enough, though I’m sure there’s probably some better way. I don’t think I’ll put PHP down on the resume quite yet… :-)

3 thoughts on “Mapping The Past”

  1. This new font is a little strange… the letters are squished together but the lines look double spaced. Very retro!

  2. That was just the default setting. I’m not much of a graphic designer. :-) I like the font, but it did seem a bit squished, and I think I’ve fixed it. I’m not sure about the comment box problem though, I’ll have to see if I can reproduce it from the office tomorrow.

  3. Just don’t tell the crew at work that you did one full line of PHP… They’ll label you the office expert. ;-)

Leave a Reply

Your email address will not be published. Required fields are marked *