<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Maggie Nelson &#187; http</title>
	<atom:link href="http://maggienelson.com/tag/http/feed/" rel="self" type="application/rss+xml" />
	<link>http://maggienelson.com</link>
	<description>databases and code goodness</description>
	<lastBuildDate>Tue, 06 Apr 2010 17:24:02 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>From MovableType to WordPress in 301 Easy Steps</title>
		<link>http://maggienelson.com/2009/01/from-movabletype-to-wordpress-in-301-easy-steps/</link>
		<comments>http://maggienelson.com/2009/01/from-movabletype-to-wordpress-in-301-easy-steps/#comments</comments>
		<pubDate>Sun, 25 Jan 2009 22:50:07 +0000</pubDate>
		<dc:creator>maggie</dc:creator>
				<category><![CDATA[entry]]></category>
		<category><![CDATA[http]]></category>

		<guid isPermaLink="false">http://maggienelson.com/?p=105</guid>
		<description><![CDATA[I&#8217;m finally caving in and switching to WordPress.  I tried it long long time ago and was annoyed by some of its code (it&#8217;s not always pretty) and the fact that pages are never cached &#8211; there are a lot of on-demand database requests.  But it&#8217;s been a while and things seem to have improved [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m finally caving in and switching to WordPress.  I tried it long long time ago and was annoyed by some of its code (it&#8217;s not always pretty) and the fact that pages are never cached &#8211; there are a lot of on-demand database requests.  But it&#8217;s been a while and things seem to have improved &#8211; some within WordPress itself, but others due to the help of the community which has provided tons of plugins that can help WordPress get around some of its problems.</p>
<p>The move from MovableType to WordPress was easy.  WordPress has import functionality that plays very nicely with MovableType&#8217;s exported files.  Yay!</p>
<p>What got me, though, is how to handle making sure that visitors to my old site would know to come to the new site.  Long time ago, I&#8217;d think to just take everything down and have a page saying &#8220;stuff has moved, deal with it, here&#8217;s the new URL&#8221;, but that&#8217;s not really very user friendly.  Michael Bloch points out <a href="http://www.tamingthebeast.net/articles3/spiders-301-redirect.htm">here</a> the not-so-good approaches for moving your site and recommends using the <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html">HTTP status code 301: Moved Permanently</a>.  This will make everything magially work: users will be redirected properly and search engines will know that the resources have moved and start looking for them in the new places.</p>
<p><span id="more-105"></span></p>
<p>When using 301, you have two choices:</p>
<ul>
<li>have a list of ALL the URLs on your previous site and have 1:1 (or close to it) redirects for each of them</li>
<li>create broad blanket rules to handle almost all of the URLs and handle the few stragglers as special cases (if any)</li>
</ul>
<p>I went with #2, because it just hurts me so to hard-code too many things.</p>
<p>The first biggie when using WordPress is that you&#8217;re probably going to set up pretty URLs for permalinks to your entries (this is done under Settings).  If you do, your .htaccess file will already contain:</p>
<blockquote><pre>RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]</pre>
</blockquote>
<p>This is the .htaccess on the new domain.  Keep this in mind because these rules may affect with any other rules you add if you don&#8217;t chain them properly.</p>
<p>Ok, the next step was handling the old site: <a href="http://www.objectivelyoriented.com">www.objectivelyoriented.com</a>.  This was easy &#8211; I added a .htaccess file in the web root that contains:</p>
<blockquote><pre>Redirect 301 / http://maggienelson.com/</pre>
</blockquote>
<p>This means that any URL from objectivelyoriented.com will be sent to the same URL on maggienelson.com.</p>
<blockquote><pre>objectivelyoriented.com -&gt; maggienelson.com
objectivelyoriented.com/maggie-is-totally-awesome/ -&gt; maggienelson.com/maggie-is-totally-awesome/
objectivelyoriented.com/i_like_php_so_much.html -&gt; maggienelson.com/i_like_php_so_much.html</pre>
</blockquote>
<p>This is pretty lenient, but we&#8217;ll remove some of the leniency a little later on with additional, more explicit rules.</p>
<p>Now, the problem here is that while MovableType and WordPress are both blogging applications, they handle their URLs differently, even though they both base the pretty URLs on the title of each entry and the month and year when the entry was published.</p>
<p>In MovableType, URLs are prettified like this:</p>
<blockquote><pre>/YYYY/MM/words_in_the_title_of_entry.html</pre>
</blockquote>
<p>MovableType will use only up to 6 words of the title of the entry and will truncate the last word if necessary to keep the length of the URL not too crazy (I admit, I was too lazy to actually check the exact limit).</p>
<p>In WordPress, URLs are prettiefied like this:</p>
<blockquote><pre>/YYYY/MM/words-in-the-title-of-entry/</pre>
</blockquote>
<p>WordPress does not have a limit on how many words from the title it will use.</p>
<p>Please note that in WordPress, you have freedom to change the prettifcation patterns &#8211; mine just happen to also have the month and day.  If you remove them, you will have to change the RewriteRules slightly.  But if you&#8217;re playing with URL prettification, then I&#8217;m assuming that you care enough to figure out what you&#8217;re doing.</p>
<p>Moving on.  As you can see, the URLs in MovableType and WordPress are pretty similar.  Both strip any non-alphanumeric characters from the URL and lowercase the remaining string.  The big difference is the use of underscores in MovableType and hyphens in WordPress.  MovableType also ends all URLs in &#8220;.html&#8221;, which we&#8217;ll need to strip for MovableType.</p>
<p>First, I handled the underscore-to-hyphen transformation along with the stripping of .html, but only for URLs that contain up to 5 words in the title of the entry.  Any of these URLs on the old site will be redirected to the equivalent URL on the new site &#8211; so you will see the entry you were after.</p>
<blockquote><pre>RewriteRule (200[6-9])/([0-9][0-9])/([a-z]+)_([a-z]+).html$ /$1/$2/$3-$4/ [R=301,L]
RewriteRule (200[6-9])/([0-9][0-9])/([a-z]+)_([a-z]+)_([a-z]+).html$ /$1/$2/$3-$4-$5/ [R=301,L]
RewriteRule (200[6-9])/([0-9][0-9])/([a-z]+)_([a-z]+)_([a-z]+)_([a-z]+).html$ /$1/$2/$3-$4-$5-$6/ [R=301,L]
RewriteRule (200[6-9])/([0-9][0-9])/([a-z]+)_([a-z]+)_([a-z]+)_([a-z]+)_([a-z]+).html$ /$1/$2/$3-$4-$5-$6-$7/ [R=301,L]
RewriteRule (200[6-9])/([0-9][0-9])/([a-z]+)_([a-z]+)_([a-z]+)_([a-z]+)_([a-z]+)_([a-z]+).html$ /$1/$2/$3-$4-$5-$6-$7-$8/ [R=301,L]</pre>
</blockquote>
<p>Yes, this was kind of ugly, but as far as I know, there is not way to do a search and replace on URLs when rewriting them (if you know of a way, I&#8217;m all ears!)  Note that this goes before the rewrite conditions and rules for the WordPress URL prettification.</p>
<p>Then, I handled all URLs that have 6 or more words.  These will not be redirected to the equivalent entry, but instead, simply to the archive page for the year and month when this entry was published.  This works for me as my blog was not yet chockful of entries, so each per-year-per-month archive contains only few entries.  This might not work for you, but the choice I made here was between how long it would take and the payoff.  Basically, &#8220;close enough&#8221; was the result.</p>
<pre>RewriteRule (200[6-9])/([0-9][0-9])/([a-z0-9_]+).html$ /$1/$2/ [R=301,L]</pre>
<p>The last thing of note is that MovableType provides some search functionality, which is accessed at /mt/mt-search.cgi?[a bunch of search params here].  As the search engine is different withing WordPress, I did not bother to transform the search parameters and instead I&#8217;m simply moving all old search requests to the new search form, like this:</p>
<blockquote><pre>RewriteCond %{QUERY_STRING} .
RewriteRule mt/mt-(.+) /#searchform? [R=301,L,NE]</pre>
</blockquote>
<p>NE means &#8220;no escape&#8221; and is necessary in this case: if you omit it, # will become URL encoded.</p>
<p>This also takes care of any remaining MovableType native files &#8211; if you&#8217;re trying to find some admin functionality or anything else, you&#8217;re bounced to the search form on the new site as there aren&#8217;t really equivalents for them on the new blag.</p>
<p>Last but not least is handling the old blogs feeds.  The MovableType installation I had provided these feeds-related files: atom.xml, index.xml, index.rdf, rsd.xml.  I have not found the equivalent of these in WordPress, so I&#8217;m simply bouncing all of those to /feed/</p>
<blockquote><pre>
RewriteRule atom.xml /feed [R=301,L]
RewriteRule index.xml /feed [R=301,L]
RewriteRule index.rdf /feed [R=301,L]
RewriteRule rsd.xml /feed [R=301,L]
</pre>
</blockquote>
<p>That about covers it.  As you can see, a lot of my choices were not extremely well researched and many of them were done on a hunch about MovableType&#8217;s and WordPress&#8217;s behaviors, but I&#8217;m really enjoying this part of MovableType: it works even if it&#8217;s not perfect.</p>
<p>For reference, here&#8217;s the two .htaccess files I created: <a href="/docs/htaccess-objectivelyoriented.txt">on the old site</a> and <a href="/docs/htaccess-maggienelson.txt">on the new site</a>. </p>
]]></content:encoded>
			<wfw:commentRss>http://maggienelson.com/2009/01/from-movabletype-to-wordpress-in-301-easy-steps/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>
