Moving Stuff Finished :-)
Yesterday evening I followed the excellent instructions from the WordPress Codex on Migrating from Movable Type to WordPress. This proved to be extremely easy with all the posts, categories and comments coming through perfectly.
I had some files (photos, ppt etc) manually uploaded, so logged in to move those over. As well as migrating I moved the blog from /blog/ up to the root of the site. That all went swimmingly and I picked a nice shiny new theme called demar.
The only thing left was to sort out redirects for all the old links - so I don’t lose all the link love I’ve managed to build up over the years.
After reading through the various options I had a few issues. I’d tinkered a bit with the MT URLs in the past and had a lot of legacy stuff hanging around. I decided I’d just do it with apache’s .htaccess. Not a choice for everyone, but my regex skills aren’t too shabby, so I figured I’d start there.
The URLs fell into a few different patterns:
/blog/atom.xml, index.xml, etc - the feeds. For now these can all redirect to /feed/ so we start with
RewriteEngine On
RewriteRule ^blog/atom.xml$ /feed/ [L,R=301]
RewriteRule ^blog/index.rdf$ /feed/ [L,R=301]
RewriteRule ^blog/index.xml$ /feed/ [L,R=301]
Feeds dealt with I moved on to the root of the blog, adding
RewriteRule ^blog/$ / [L,R=301]
RewriteRule ^blog$ / [L,R=301]
and then onto the archives, where we start to get trickier. First we have categories which take the form /blog/archives/cat_somewhere_I_put_stuff.html. WordPress creates a different pattern by default - /categories/somewhere-i-put-stuff. Not too hard, first we pull out the words, then glue them back together again.
RewriteRule ^blog/archives/cat_([^_]*)_([^_]*)_([^_]*)_(.*)\.html$ /category/$1-$2-$3-$4 [L,R=301]
RewriteRule ^blog/archives/cat_([^_]*)_([^_]*)_(.*)\.html$ /category/$1-$2-$3 [L,R=301]
RewriteRule ^blog/archives/cat_([^_]*)_(.*)\.html$ /category/$1-$2 [L,R=301]
RewriteRule ^blog/archives/cat_(.*)\.html$ /category/$1 [L,R=301]
Each of these regexs pulls out categories of 4 words long, 3 words, 2 words and 1 word respectively. If you have categories with more words in then you’ll need to add longer versions of these, ordering them longest first.
Next the monthly archives, in MT /blog/archives/2004_04.html and in WP /2004/04/
RewriteRule ^blog/archives/([0-9]{4})_([0-9]{2})\.html$ /$1/$2/ [L,R=301]
easy enough.
Then we have the individual posts. These fall into two groups, name based files and numbered files. The name based files are all /blog/archives/categoryname/postname.html. I had thought these were going to be a pig, but I discovered completely by accident that if you simply use the postname part of that then WordPress figures out which post you meant and redirects to its nice new WP URL. Sweet.
RewriteRule ^blog/archives/[^/]*/(.*)\.html$ /$1 [L,R=301]
The exception to this turns out to be posts that have a hyphen in the name. MT strips the hyphen, leaving WP with a name that doesn’t match. I put a rule in specifically for the one post I have that was affected:
RewriteRule ^blog/archives/personal/beijing_sightse.html$ /2008/05/04/beijing-sight-seeing/ [L,R=301]
Which just leaves the numbered posts: /blog/archives/000217.html. The numbered entries proved to be tricky. While you can just append the number /1234 like so and WordPress will fid a post for you, the posts weren’t matching up. As many of these had been indexed by Google and linked by others I wanted to hook them up to the right posts.
Fortunately I had Movable Type still rendering my site as static HTML files, so with a quick bit of bash magic I pulled out the numbered posts and made rules to map them to the Movable Type post name based permalinks (which we already did rewrite rules for above):
find . -type f \
| grep "^\./[0-9]*\.html$" \
| xargs grep permalink \
| awk ‘{print $1 " " $17}’ \
| sed -e ’s%^\./%RewriteRule ^blog/archives/%’ \
-e ’s%\.html:%.html$%’ \
-e ’s%href="http://www.dynamicorange.com%%’ \
-e ’s%">Permalink</a><br%%’ \
> rules.txt
Each line of rules.txt ends up looking like this
RewriteRule ^blog/archives/000285.html$ /blog/archives/semantic-web/vocabs.html [L,R=301]
which results in a second redirect to just /vocabs and then a third as WP works out where to take you finally. Not great to be bouncing around so much, but much better than losing the link.
Good luck if you decide to make the same move.
1 Comment to Moving Stuff Finished :-)
[...] If you are thinking of doing a similar move (and are of the tech inclination) I’d recommend Rob Styles post on moving from Typepad to Wordpress for information on dealing with redirecting URLs etc - something I struggled with (and still [...]
Leave a comment
Search
Right Now (ish)
- @davebriggs whatever the browser's set to minus an attractive margin? in reply to davebriggs 1 day ago
- sites that still need the http://www. on the front are so last century 1 day ago
- @moontweet appears to have (mostly) given up replying to people directly #moonfruit 1 day ago
- More updates...
Categories
- .Net Technical
- Blog on Blog
- commands I have issued
- Enterprise Architecture
- event
- Fiction Book Review
- Food
- Intellectual Property
- Interaction Design
- Internet Social Impact
- Internet Technical
- IP Law
- Library Tech
- Music
- New Toy
- Non-Fiction Book Review
- Ontologies
- Open Data
- Other Technical
- Personal
- Random Thought
- Resourcing
- Security And Privacy
- Semantic Web
- Software Business
- Software Engineering
- Talis Technical
- Uncategorized
- Working at Talis
- [grid::blogpaper]
- [grid::fatherhood]
Archive
- July 2009
- June 2009
- May 2009
- April 2009
- March 2009
- February 2009
- January 2009
- December 2008
- November 2008
- October 2008
- September 2008
- August 2008
- July 2008
- June 2008
- May 2008
- April 2008
- March 2008
- January 2008
- December 2007
- November 2007
- October 2007
- July 2007
- June 2007
- May 2007
- April 2007
- March 2007
- February 2007
- January 2007
- December 2006
- November 2006
- September 2006
- August 2006
- June 2006
- February 2006
- January 2006
- December 2005
- November 2005
- September 2005
- August 2005
- July 2005
- June 2005
- May 2005
- February 2005
- January 2005
- December 2004
- November 2004
- October 2004
- September 2004
- August 2004
- July 2004
- June 2004
- May 2004
- April 2004
- March 2004
- February 2004
- December 2003
- November 2003
- August 2003
- July 2003
- June 2003
- May 2003
- March 2003
- January 2003
- October 2002
- May 2002
- March 2002
- August 2001
- May 2001
- April 2001
- January 2001
- December 2000
- November 2000
- December 1999
- November 1999
- July 1999
June 3, 2009