arrow-left arrow-right brightness-2 chevron-left chevron-right facebook-box facebook loader magnify menu-down rss-box star twitter-box twitter white-balance-sunny window-close
Maintaining URIs between Movable Type and WordPress
2 min read

Maintaining URIs between Movable Type and WordPress

When I moved to WordPress I made the decision to change the layout of my archived URIs. To be honest, I was going to make this move under Movable Type as well, but just hadn’t got around to it. This modification amounts to nothing more than changing a uri_that_looks_like_this/ to a uri-that-looks-like-this (dashes and no trailing slash). The reasons for this aren’t worth going into right now, but if you’re interested, feel free to e-mail me.

If you initially followed my steps for future-proofing your site in Movable Type and are moving to WordPress and want to keep a similar archive structure, then follow the steps below. Even if you didn’t use my future-proofing method for MT, but are still thinking about moving to WordPress, you can probably figure out what changes would be needed to the following code to make it work for your particular setup (assuming the archive structure you used under both CMSs is based, at least in part, on the titles of the posts).

Step One

The first thing you are going to want to do is to create a new MT template which contains the following code (perhaps modified for your particular situation).

<MTEntries lastn=10000>
RewriteCond %{REQUEST_URI} <$MTArchiveDate
format=%Y/%m/%d$>/<$MTEntryTitle dirify=1$>/$
RewriteRule .* archives/<$MTArchiveDate
format=%Y/%m/%d$>/<$MTEntryTitle dirifyplus=pld$> [R,L]
</MTEntries>

Realize that the rewrite lines above should each be one long line (i.e., no line breaks).

The above code will traverse all of your Movable Type entries and create the appropriate conditions and rules for each of them, the idea being that each individual entry will get a separate RewriteRule that will direct it to the new [slightly altered] URI.

Step Two

Build this template.

Step Three

Copy the contents of the resultant file into your root .htaccess file or the one in the root of your archives directory — shouldn’t really matter. Either way, be sure to include these rules before the htaccess rules that WordPress creates (and needs to work), else the server will act on those earlier rules and never get to these.

That’s it — now all of your old MT archives should forward to the new URIs.

Beware

I noticed that Movable Type’s dirify function and the dirifyplus plugin remove dashes within a title and so if you used either of these to make your directory structure (which this little guide assumes), you’ll need to go through your entries, find those that have a dash in the title, and then reinsert that dash in the RewriteRule portion of that particular address (else, the link will be unreachable).

You've successfully subscribed to Justin Blanton.
Success! Your account is fully activated, you now have access to all content.