Final bits of WordPress migration

Two things that needed doing – the first one was that I’m a windows guy, so my site is on windows and IIS.  Apache has a nifty “mod_rewrite” add-on which lets WordPress do the cool url’s like instead of having a link to

So I’d found a WordPress URL Rewriter which worked well (as long as PHP wasn’t running as an ISAPI module).  But it needed me to add the url rewriter as an ISAPI module and I kinda wasn’t happy with having to make manual changes to my hosting setup because then upgrades/domain moves might cause issues. I wanted to have the solution I used only require me to change stuff in the plesk control panel, and not directly on the server.

With that limitation, I decided to go with the “fake 404” page solution which is mentioned in a few blogs.  Basically this works because you tell IIS that if someone requests a page that doesn’t exist (like the pretty perma-link) then it should redirect the user to the index.php page with the correct settings in place so that wordpress shows the related blog entry.   This works pretty well!

The final bit of my wordpress migration was that my old site had it at, while the new site is at (or

A basic sample of what I used can be found

So I decided to modify my little 404 page to include some redirects and I found the code below:

function redirect($url, $type=301)
  if ($type == 301) header("HTTP/1.1 301 Moved Permanently");
  header("Location: $url");
  echo ‘This page has moved to <a href="’.$url.’">’.$url.'</a>’;

And the proof is the fact that the blog should just be working at the moment, regardless of what URL you access it on.  Of course that’s assuming that its all still working now, which probably thanks to the demo god’s will fail miserably now that I’m using it as an example.

Development General

Exporting BlogML from Subtext 2.1 and importing BlogML into WordPress 2.7

I currently run by blog using Subtext and I’ve been wanting to test out some features in WordPress for a while.  So naturally I don’t want to lose all of my blog posts and I’m not keen to write a whole bunch of code to read from the one database and write to the other.

Fortunately Subtext has the ability to export to BlogML and WordPress apparently has the ability to import from anything (if you believe the rumors)  Unfortunately both the export and the import don’t really work.

Firstly, Subtext’s export doesn’t work. BUT since I had started my day thinking about moving from Subtext to BlogEngine.Net, I’d found a forum post where a friendly person showed how to make SubText export to BlogML successfully (Its the post by Harold on 2 Dec 2008).  He links to the binary of SubText.BlogML.dll – you just replace the one on your site (make sure you have a backup of your version, just in case there’s some issues with newer versions of Subtext)

Now for the import part – Thankfully Aaron Lerch had handled this back in WordPress 2.3 in his post about moving to WordPress from Blogger.   The important thing for me was his BlogML importer.

There are a few things that seem to have changed.  Aaron’s post uses “XPath.class.php” which you can get from Sourceforge.  It suggests that you put the file in the /wp-admin/import folder, but that just seems to cause issues.  So I’m going to lay out the steps that I took over here:

  1. Download “XPath.class.php
  2. Put the file in your /wp-admin/ folder
  3. Edit /wp-admin/admin.php and add a line at line 27 so that the file looks like:
    require_once(ABSPATH . ‘wp-admin/includes/admin.php’);
  4. I’ve modified Aaron’s blogml importer and you can get blogml.php.
  5. Upload it to your /wp-admin/import folder

The original blogml had a few issues:

  1. It couldn’t handle &nbsp; or &gt; or even &lt; in any of the blog posts
  2. Categories were not imported correctly at all
  3. It didn’t, and still doesn’t, handle draft posts at all.
  4. It didn’t work with WordPress 2.7

I managed to fix the problems with the escaped html, the categories and the WordPress 2.7 issues, but didn’t quite get to fixing the issue with the draft posts.  Let me know if you manage to fix that part – I only had one draft post so it didn’t really matter.  Hopefully this will help someone else though.