How I moved from Movable Type to WordPress

So yesterday I put out a call for help to get my Movable Type archives pointing to the new permalink format in WordPress.

Erik was nice enough to answer my plea, as he usually is about this stuff (thanks again!) and he came up with a solution that not only worked, but is much easier than other methods I’ve seen.

As he said in the comment here, I couldn’t redirect to a longer URL. The catch is that my Movable Type permalinks that are linked all over the place had basenames (name_of_the_file.php) that were no longer than 30 characters. WordPress defaults to a directory name (that replaces the file name) that is as long as the title.

So a post that was titled, “This is a very long entry title that says a lot of stuff” would be

/momathome.com/viewfromhome/2006/01/this_is_a_very_long_entry_title.php

by default in Movable Type, and it would be

/momathome.com/2007/01/01/this_is a_very_long_entry_title_that_says_a_lot_of_stuff/

in WordPress (with the Underscore Permalinks plugin).

To use a .htaccess redirect (mod_rewrite) I had to make the two URLs match up better.

First the easiest part. A custom permalink structure drops the day out of the URL:

/%year%/%monthnum%/%postname%/

After importing all my entries, I ran this MySQL command in phpMyAdmin:

UPDATE wp_posts SET post_name=SUBSTRING(post_name,1,30)

where “30” is the basename length from Movable Type. That truncates the slug (post_name) at the required 30 characters for those older entries.

Then it was easier (with Erik’s help again) to put the block below in my .htaccess file to 1. drop the “viewfromhome” directory from the paths and 2. change the .php at the end of the file to /.

RewriteEngine On

RewriteBase /

RedirectMatch /viewfromhome/(.*)\.php$ http://www.momathome.com/$1/ [R=permanent]

RedirectMatch /viewfromhome(.*) http://www.momathome.com/$1 [R=permanent]

RewriteRule ^(2…/.*)\.php$ /$1/ [R=permanent,L]

WordPress is a wonderful tool for bloggers. I’m glad to finally make it to the party.

Advertisements