Undercrank

Scripting

December 15, 2004

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.

More of the same RSS

Yahoo! Web Services news over Atom

aka: "When you realise Yahoo! already serve their news over RSS..."

Yahoo! Web Services news over RSS

I've put together a small project that will create an dynamic RSS 2.0 feed based on the Yahoo! News Search hooks.

Despamming Shortstat (Part 2)

Further to my earlier post about Despamming Shortstat, I've made a small update to the code that has a few improvements on the original.

Importing CSV files to SQLite

"SQLite is different from most other SQL database engines in that its primary design goal is to be simple". Which isn't strictly true...

Post a comment

Remember personal info?