How-to Change a Movable Type URL Structure and Survive to Tell About It

My buddy and (sleeping yet awake) business partner John "summer cold" Engler asks me to explain how I handled our change in URL structure last month at Up2Speed (2004 update: now called MarketingVox), so here we go.
My first goal was to change our URL structure for individual archives from:
http://www.up2speed.com/archives/name_of_entry.php#uselessnumber
To:
http://www.up2speed.com/archives/yyyy/mm/dd/name_of_entry/
You’ll recognize the former as something fairly standard on MT blogs (John’s archives are just like that), while the later is the kind of stuff we anal retentive types tend to love. If the "move up the directory structure" icon in the Google toolbar is a standard navigation tool for you and you’re upset when that doesn’t work on some silly site, you and I will bond like vanilla ice cream and hot chocolate fudge (I’m doing the hot fudge part, ok).


Anyway, I won’t explain now why I wanted that kind of URL structure past using bad metaphors (you’re still looking for some hidden sexual meaning, aren’t you?), it’s been documented at length in the past and at John’s site. Other date-based archives, and category archives, had to fit within a similar logic.
Being a greedy marketer at heart, my second goal was to prevent FREE search engine traffic from being lost through the shuffle, so I wanted to permanently redirect all the old pages to their new place.
Here are the steps I went through:
0. During about three weeks, learnt MT by playing with it on a test blog, reading its doc, reading and posting in its support forum, reading some other excellent resources (sorry, I’m sure I’m forgetting some): Brad Choate, the girlie matters, Phil Ringnalda, Adam Kalsey (thanks for the tips about comments today), Mark Pilgrim, and our own John. I also learnt some basics about PHP and mod_rewrite, since I was an absolute newbie on the LAMP platform. (Please keep buying Microsoft products and stock, I’m a shareholder!)
1. Investigated right before doing it that directory depth isn’t a liability to search engine indexing (John scared me for a little while). Apparently it’s a myth if you make sure it doesn’t take too many links from your home page to your your "deep" directories/pages. All our pages are at most two clicks away from the home page, so I thought, all is a-ok, let’s go.
2. With the individual entry path still set at <$MTEntryTitle dirify="1"$>, replaced the individual entry template to:
<$MTEntryTitle dirify="1"$>/";
$NewUrl = "http://www.up2speed.com/archives/" . $NewUrl;
header("HTTP/1.1 301 Moved Permanently");
header("Location: $NewUrl");
exit();
?>
(Seems blogger is eating the opening php statement, but I can’t bother to learn how to escape it and you’ll figure it out.)
This is in compliance with what Google recommends to do.
2. Rebuilt individual entries. Took 30 seconds for 1,500 entries since the template is so small. Yes, at this point, I was pointing people into the void, but I did this on a July Sunday for a B2B site, and besides, that’s the kind of lazy bastard I am. Go write your own procedure (or just tweak this one).
3. Changed the individual entry path (in MT’s archiving settings) to:
<$MTArchiveDate format="%Y/%m/%d/"$><$MTEntryTitle dirify="1"$>/index.php
4. Changed the individual entry template with my New and Improved template.
5. Rebuilt individual entries. This time it took several minutes as that template is rather heavy.
6. Added the following lines to our root .htaccess file to redirect monthly and category archives pages which were easy to handle through regexp thanks to their previous structure.
Options +FollowSymLinks
RewriteEngine on
RewriteRule archives/200([0-9])_(.*)(\.php)$ http://www.up2speed.com/archives/200$1/$2/ [R=301]
RewriteRule archives/cat_(.*)(\.php)$ http://www.up2speed.com/archives/categories/$1/ [R=301,L]
7. Rejoiced that somehow my first project involving MT and Apache worked! Try this for yourself:
http://www.up2speed.com/archives/french_ban_email_the_word.php#005071
Additional note: internal links look like this in our templates:
<*=str_replace("index.php","","<$MTEntryLink$>")*> (replace * with ?, damn Blogger)
to remove the useless index.php and provide a clean, platform-independent directory structure (to prepare a future migration to .NET, mwahahah).
Training aside, it took me a lot less time than other people need to reinstall Windows XP. (Why you’d want to do that in the first place, I’m not sure, I’ve not reinstalled XP Pro on this PC for two years, and I’m tweaking the OS settings to death, playing all sorts of games, playing MIDI music and editing DV video with it among other things, but whatever. OK, my XP notebook would definitely need a reinstall after just 9 months, I’ll grant you that).
You can navigate through our marketing news archives (both time-based and category-based) to see how it’s all connected. I don’t use any plugins there, just some PHP hackage.
08/10/03 update: Friday Feast #55: Friendly, Lasting URLs
08/12/03 update: John did it, with slight changes.

Leave a Reply

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