Redirecting Movable Type Blogs to WordPress

So yesterday was a bit of a scavenger hunt through the bowels of incredibly old articles on the Internet, resulting in a few dead-ends, some u-turns, false starts and finally pretty successfully accomplishing my goal.

You see, a friend asked how she could redirect her old Movable Type blog to her new WordPress blog so that when people look for her via Google, they will find her most current version. It seems pretty straight forward at first, and if we were just thinking about the high level domain/url for her MT blog, to her WP blog, you’d think a simple 301 redirect would do the trick. But what about all of the individual pages? The Category Archives? The Monthly Archives? Not to mention all of the tags? Redirecting Movable Type Blogs to WordPress is not as straightforward as it seems. If you don’t care about the journey, skip down to the bottom, Redirecting Movable Type Blogs to WordPress Step by Step.

Redirecting Individual Entry Archives

Let me state right off the bat that a lot was written about this … 7 – 11 years ago! That’s right because you see, the version of Movable Type in this case is from 2006 and when WordPress first came on the scene, lots of people were migrating from Movable Type to WordPress, so there was a need for some easy to understand instructions. Unfortunately, though what this meant to me was that a lot of these articles were, well, gone. Let me also state that this assumes you’ve already imported your entries from Movable Type to WordPress and you’ve used entry URLs are formatted in Movable Type as (where .ext is html, htm, php, etc. – more on this later) and your WordPress URLs (permalinks) are If you need help with the import, check out: Importing Movable Type 3.x Blogs into WordPress.

To start, I had this article in the WordPress archives: Importing from Movable Type to WordPress. It’s got the basic steps you need to move your blog (import/export) from Movable Type to WordPress but not much on the redirection. It did have a valuable clue, referencing Alex King’s Movable Type Template for Individual Entries, “which you can use to generate pages that will redirect visitors to the corresponding WordPress pages.” That’s exactly what I needed!

Unfortunately, the link was broken. It did get me to AlexKing.Org (side note, Alex King was one of the original developers of WordPress). Doing a search though on his blog using the term “Redirecting MT Entries”, led me to this post, “Redirecting MT Entries to WP” which led to his WordPress Hacks and to Jonathan Green’s Moving from Movable Type to WordPress.

On the Hacks page (you need to page down), you’ll find, “Redirect MoveableType to WordPress Template” which you can download. It’s a zip file that contains a PHP template for 301 redirection, an html template for redirection and a readme file. Looking back, here’s about the time I took my first misstep (but I’ll explain why later).

A Sidebar – on SEO (Search Engine Optimization)

It’s one thing to redirect your old Movable Type blog to your new WordPress blog, but it’s another to do it in such a way that search engines (e.g., Google), know that this redirection is permanent and that you don’t want them to look at your old blogs any longer. To do this, you want to use a 301, Permanent, Redirect, which is why right off the bat I chose the PHP template to use for the individual entries and dove right in. You see, it uses a 301 redirect where the HTML template uses a javascript relocate and I’m not sure how search engines interpret that and if they dislike it.

Back on the Redirection Course

Anyway, once I made the decision to use the PHP template, I went over to the MT installation, backed up the existing Individual Entry Archive, and then copied over it with the PHP template, changing the URL in the template. I rebuilt the blog but the new entries did not redirect. I looked at the code and realized (and honestly it clearly states), that the template assumes the URLs are of the format, So I took out the code for the days (dd) and rebuilt the blog. It still didn’t work. I added this line to the code, "$title = str_replace('_', '-', $title);" because it seemed to me there was nothing in the function that converts the underscores in the title to dashes (of course, I could be wrong). It still didn’t work.

So I returned to Jonathan Green’s article since he stated that he got this template to work. That’s when I notices he stated:

I should note here that you will have to change the way MT generates pages BEFORE using the new template.


So I reread that paragraph again. Yep, you see all the pages on this blog had an .html extension. They needed to be php. But before I accepted that, I re-read Alex’s Read Me file, where he stated,

If you have .html archives but want to use the .php redirects, you can put this in a .htaccess file in your MT directory:

AddType application/x-httpd-php .html

Then all your .html pages will be parsed by PHP

That seemed easier and more straight forward and since I had FTP access to the blog, I created an .htaccess file and uploaded it to the server.
It still didn’t work.

Returning to Jonathan’s advice, I returned the Individual Entry Archive to its original form, rebuilt the blog (so all the html pages returned), went into Settings–>Publishing on the MT Installation, changed the File Extension for Archive Files from html to php (no period), clicked Save, then returned to the Templates.

In Movable Type - changing file extension from HTML to PHP

In Movable Type – changing file extension from HTML to PHP

Then, in the Templates–> Archives, I opened the Individual Entry Archive, copied back in the template file for PHP (with the changes to only do YYYY-MM files directories), saved it and rebuilt the blog.


The blog rebuilt with the individual pages having the php extension and those pages automatically redirected to the new blog location!

Wait though. What about all those html pages for the blog? Weren’t they still out there? Oh, and didn’t Google still point to those pages not the php pages that were now redirecting? So yes, while from the MT Blog home page, the links redirected to the new WP blog, it didn’t help with the search at all.

Rereading Jonathan’s article yet again and saw this:

I am still working on a .htaccess redirect for my .html files to redirect to the .php ones so that they can take advantage of the new template as well. This will automatically push someone from Google to the right spot in my WordPress site. Right now I am getting a 500 Error and will need to try again in the am… – See more at:

Great. I already tried using an .htaccess file and it didn’t work. That’s when something jogged in my memory. You see, .htaccess files are used on servers that operate under Apache and well, I had the sinking feeling that the server on which the MT blog resided was a windows-based server. There was no using an .htaccess file.

So now I was sent researching how to do redirects (now I needed to redirect the MT .html files to the MT .php files which in turn would then redirect to the new WP blog) on a Windows platform. The results weren’t encouraging. The prevailing opinion through the myriad of articles I read seemed to state that they only way to do this was through the admin panel, one file at a time, I had neither the access or desire to do that.

Then I found some articles that indicated I could accomplish this through the web.config file. Long story short though, I could not get this to work either.

Through all this reading, I did see something about using javascript in html to redirect the page to a new site, so I started to investigate that methodology.

The first issue I realized was how would I tell the Javascript the name of the PHP file to which it needed to redirect. I began investigating the manipulation of the MT tag, $MTPermalink which contains the URL of the blog entry. Unfortunately, here I ran into another major roadblock. You see, as I mentioned before, the version of MT used on the blog was woefully out of date and at some point Movable Type removed all of the supporting documentation from this version. I did find some more current documentation that referenced a “Replace” function in correspondence with the current incantation of the MTEntryPermalink field. So I hoped perhaps it was present in our older version. Unfortunately, the replace function did not work.

Then through some more digging I stumbled upon a Japanese blog (I used Google Translate), which had a Movable Type Plugin that appeared would send the Permalink to a corresponding alias. It worked beautifully! Unfortunately though only if the original URL and the Alias URL were explicitly spelled out and it only had places for five aliases. So no using wildcards and no more than five pages could be redirected.

Back to the Javascript issue. That’s when it hit me, I could come up with the PHP file name by recreating it from the Title and Entry date in a similar way to the PHP template, using the Movable Type tags. Here’s a bit of the code that works:

<MTSetVarBlock name=”PHPFileName”><$MTArchiveDate format=”%Y/%m/”$><$MTEntryTitle dirify=”1″ trim_to=”30″$>.php</MTSetVarBlock>

This creates the PHP file name in the variable PHPFileName. Note though the “trim_to” field. This truncates the Entry Title in the same way Movable Type does when creating the Permalink. Make sure yours it’s not longer than your longest file name.

Finally I had the correct url! I put that bit of code in the Head section of the Individual Archive Template (the original one that builds the html pages), right before the end. Then in the body section, at the beginning, I placed:

Redirect Using Javascript

I’m not sure I had to do it this way. I may have been able to $MTGetVar command right into the location.replace but when I did try that initially, it didn’t work (later I realized I had a typo so I’m not sure if that was the cause for it not working). In the end though, this worked so I kept it!

The Original Error to Which I Alluded

So now I have html versions that redirected to the php versions that redirected using a 301 to the new blog for each individual entry. I’m not sure how this will affect the SEO as the 301 is on the php version not the html but at this point I can’t afford more time on this issue. It’s this morning though, when I went through these steps in my head that I realized if I was giving up on the 301 redirect, I could have just put this bit of code in the html files via the Individual Entry Archive and had them point directly to the new blog. Oh well.

Now, about the other pages in the blog…

Redirecting Movable Type Blogs to WordPress Step by Step

So now we know there are two ways. Using PHP header with a 301 or using Javascript in html.

Using PHP 301 Redirect in the Individual Entry Archive

1. In your html version (if you are starting with html) of your Individual Entry Archive add this code:

<MTSetVarBlock name=”PHPFileName”><$MTArchiveDate format=”%Y/%m/”$><$MTEntryTitle dirify=”1″ trim_to=”30″$>.php</MTSetVarBlock> in the Head section, just before the end. Ensure that your Individual Entries follow the naming convention, “” and make sure your trim is to the correct number.

2. Also in the html version of your Individual Entry Archive, just after the “Body” starts, add this code:

Redirect Using Javascript

3. Rebuild all of your Individual Archives.

4. Now using the PHP by Alex King, referenced above, copy that into your Individual Entry Archive file (paying attention again to the use of days in your archive URL).

5. In Settings–>Publishing, change the file extension (as shown above) to PHP. Rebuild your individual archives again. Now all of the individual pages will redirect to your new blog.

Using Javascript in the Individual Entry Archives via HTML

1. If you don’t care about the 301 redirect, this is much easier. In your html version of your Individual Entry Archive add this code:

<MTSetVarBlock name=”PHPFileName”><$MTArchiveDate format=”%Y/%m/”$><$MTEntryTitle dirify=”-” trim_to=”30″$>.php</MTSetVarBlock> in the Head section, just before the end. Ensure that your Individual Entries follow the naming convention, “” and make sure your trim is to the correct number. Note: the dirify is changed from a “1” to a “-” this will return the entry titles with a dash where the spaces are in the Entry Title, making it suitable for a WordPress URL.

2. Add the Javascript from above.

3. Rebuild the Individual Archives and you’re done.

 Using Javascript in the Category Archives via HTML

It’s all very similar to the Individual Entry Archives, again, not worrying about the 301 redirect, add this code to your Category Archive page near the end of the head section:

<MTSetVarBlock name=”NewFileName”><$MTArchiveTitle dirify=”-“$>/</MTSetVarBlock>

Same javascript as above (though note, I changed the variable name to NewFileName to be more generic. If you use it, you’ll need to update the javascript accordingly).

Using Javascript in the Date Based Archive

Again, all very similar. Add the code below to the Head section just before the end:

<MTSetVarBlock name=”NewFileName”><$MTArchiveDate format=”%Y/%m/”$>/</MTSetVarBlock>

Same javascript as above (though note, I changed the variable name to NewFileName to be more generic. If you use it, you’ll need to update the javascript accordingly).


Unfortunately I haven’t figured out how to redirect these yet.

Overall Site

When you’re done with the above, change your main index template to output to php. Then using a modified version of Alex King’s template, to this:
Redirecting Movable Type to WordPress

Then save and rebuild. That’s it, your site will totally be forwarded to the new domain.


Comments are closed.