Pointing older Movable Type files to WordPress

Whilst helping out with a friend’s blog that’s running WordPress, one of the issues that arised was that he had heaps of static archive files from a previous Movable Type installation that he was unable to integrate into WordPress (it’s a long story).

In the meanwhile we uploaded the archive files as they were so that Google was kept happy, but the problem remained that a bunch of the links in those static pages needed to be redirected to their WordPress equivalents – for example, the RSS feed and the search script. After a lot of noodling, hopefully the following lines of code inserted into your .htaccess file will help if you have similar problems:

Redirecting links to the RSS 1.0 and 2.0 feeds

Using Apache’s Redirect directive; (replace yoursite.com with the appropriate URL):

Redirect /index.rdf http://yoursite.com/feed/rdf/

Redirect /index.xml http://yoursite.com/feed/rss2/

Redirecting the Movable Type search script

This one was a pain to figure out – mod_rewrite uses the black art of regular expressions, but cutting a long story short:

RewriteCond %{QUERY_STRING} search=([^&;]*) [NC]

RewriteRule ^cgi-bin/mt-search.cgi$ /index.php?s=%1 [R=301]

Which will take the search parameter from a request to /cgi-bin/mt-search.cgi and send a 301 Moved Permanently status code and the location of the main WordPress file – in this instance, it’s index.php.

In real life, this example:

/cgi-bin/mt-search.cgi?search=Hello+World

would now map to:

/index.php?s=Hello+World.

This entry was posted in Scripting and tagged , , , , , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>