Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/rekall/ on line 74

if you’ve divorced movabletype, successfully exported and imported your existing posts, and eloped with wordpress, undoubtedly you’ll want to maintain all the inbound links google and other search engines have accumulated over time so that your adoring public will still be able to locate your scribblings…

here are the three most important classes of url’s to preserve:

1. category

MT — /archives/{category_name}
WP — /category/{category-name}

2. monthly archive

MT — /archives/{year}/{month}/
WP — /{year}/{month}/

3. post

MT — /archives/{year}/{month}/{slug}.html
WP — /{year}/{month}/{day}/{slug}/

you’ll note that none of the wordpress url’s contain the archives/ prefix. you can use this to your advantage in the url rewrite rule you’ll define in your .htaccess file.

RewriteRule ^archives/(.*) mt-wp.php?$1

in the above example, everything after archives/ in the incoming url will be passed to a php script called mt-wp.php which will do the work of determining which of the above three url classes it is, reformatting the url to the appropriate one used by wordpress, and either redirecting to that url or serving it up by proxy.

for [1] you will merely replace underscores with dashes. for [2] you will use the query string as-is. [3] is slightly trickier and is the reason why you’ll handle redirection (or proxy, using a socket connection or the cURL library) in a [insert language du jour here] script instead of a set of three RewriteRule’s.

movabletype’s post slugs are more brief than the ones wordpress generates, and, whereas movabletype does not include the full date of the post in its url, wordpress does.

unless you were in the habit of writing a slew of posts any given month with utterly similar headlines, it should be sufficient to use just the first two words from movabletype’s slug, in addition to the month and year, as keys to locating that post in your wordpress database. break up the slug portion of the url into words using the underscore as your delimiter, and concatenate the first two words together with a dash: word1_word2_word3 becomes word1-word2.

now, query:

SELECT guid FROM wp_1_posts
WHERE post_name LIKE ‘{word1}-{word2}%’
AND post_date LIKE ‘{year}-{month}%’

i find it wonderfully convenient, especially for the purposes of this exercise, that wordpress provides the full url to the post in the guid column.

*substitute wp_1_posts for the table containing the posts you’ve imported from movabletype.

if you’ve been following so far, generating code in your language of choice to do all of this should be a walk in the park. i leave it to you…