Use .htaccess to redirect from Drupal to WordPress

As I mentioned, I just converted from Drupal to WordPress, and one of the most difficult parts of the conversion was figuring out how to redirect Drupal's old urls to the new equivalents in WordPress.  I'd taken care to carry over ID values intact, so the mapping was easy, and Apache should have been quite capable of doing the url translation for me, but it took a fair bit of trial and error to get it to work right.

Here's the file that finally worked:


#
# Apache/PHP/Drupal settings:
#

# Various rewrite rules.
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine on

# Rewrite drupal urls to worpress
RewriteCond %{QUERY_STRING} ^q=node/(.+)$
RewriteRule ^(.*)$ http://blog.componentoriented.com/?p=%1 [R=301,L]

# Forward RSS feed
RewriteCond %{QUERY_STRING} ^q=rss.xml$
RewriteRule ^(.*)$ http://blog.componentoriented.com/?feed=rss2 [R=301,L]
RewriteCond %{QUERY_STRING} ^q=atom/feed$
RewriteRule ^(.*)$ http://blog.componentoriented.com/?feed=rss2 [R=301,L]

</IfModule>

Notice the use of RewriteCond before RewriteRule.  When I originally tried this, I used only the RewriteRule statement and tried to match the query string in the first part of the RewriteRule statement.  Needless to say, it didn't work.

The problem turned out to be that RewriteRule just wouldn't match query strings (which is where the node ID was), and when I figured out how to use RewriteCond, that turned out to be exactly what I needed.  The %1 instead of $1uses the value that was matched in the previous RewriteCond statement rather than the matched value in RewriteRule.

Finally, you can see that I also forwarded the old Drupal RSS feeds.  If you're converting from Drupal, this should work for you, and if you're converting from anything else, hopefully this example will help a bit.

Now running on WordPress

If you're a regular visitor, you probably notice a few changes here – I just converted from Drupal to WordPress. There wasn't a single big reason to convert, but rather a bunch of little reasons, like these:

  • I was looking at a Drupal upgrade to stay current, so I was at a point where I had to get off my duff and do something, anyway.
  • I really liked the clean look of WordPress blogs when I visited them, and I never quite found that in a Drupal theme. Maybe I wasn't looking hard enough, though…
  • When I moved from PostNuke to Drupal, one of the big reasons was for increased community activity, standards support, and ease-of-use, and it's the same story again here. WordPress has really taken off as a community and a platform, and I see tools and services generally supporting WordPress before Drupal, and frequently with higher quality.

I still really like Drupal, and I think in situations where maximum flexibility and extensibility are needed, Drupal still has more headroom. But I'm just a blogger, you know, and this suits me just fine, thank you.

You'll also notice that I've changed my URL. I've decided to go to a .com extension in hopes of boosting google juice, among other things. All your bookmarks and google searches should get directed here automatically, thanks to some work in .htaccess (I'll post on that later). Same goes for RSS, but if you've added my feed to your reader, please take a second to fix up the address and avoid the redirect – the new RSS address is http://blog.componentoriented.com/?feed=rss2.

Thanks, and feel free to comment on the new design.

Free .Net Development

I saw an interesting question a couple of days ago on a Joel-on-software forum:

http://discuss.joelonsoftware.com/default.asp?joel.3.668628.7

A poster lamented that his company had a rather "mature" IT platform, with a bunch of classic ASP code, Windows Server 2003, SQL Server 2005, and Office 2000, and the maintenance of the ASP code was getting prohibitively difficult.  He asked the group's opinion about using the free "Express" editions of .Net versus making a platform switch to something like Java, which is "100% free".

You can read my response there, of course, but I'd like to expand on it a little here, because I think this scenario is really pretty common, and because I think the obvious problems here really do a pretty good job of masking some serious underlying problems, and I think most people are going to miss those.  In fact, I'm going to do this as a two-part post, because both problems merit some discussion.

vsexpress On to the first problem - can you really do .Net development for free using the Express tools?

You bet you can.

The Express editions target the very same .Net 3.5 runtime platform as other Visual Studio tools.  If you need to build large-scale Enterprise applications with the very latest bells & whistles, you might miss some of the features in higher-end versions of Visual Studio, but the real make-or-break feature is source code control integration.  The idea here is pretty simple - source control integration is nice for individual developers, but it's a must-have for teams, and if you're developing in a team, Microsoft's position is that you really should upgrade.  I think this makes sense, and it still provides an incredible amount of room for smaller-scale development.

I think the best way to think about this is to compare VS Express to whatever you're using today, and look at all the value you'd get for free.  VS Express supports Master Pages, LINQ, MVC, Dynamic Data websites, and more.  You can target the platform for your application (making VS 2008 the best platform you can use for developing .Net 2.0 applications).

Even if you decide to upgrade to a more capable version of Visual Studio, by the way, you should definitely check out the web resources for the Express Editions - there's a lot of great content there.  Finally, I'm not sure if this is still true, but when I downloaded the Express Editions and registered them, I was able to download some free third-party controls, including SpreadsheetGear, which is worth the price of admission all by itself.

So, to paraphrase (badly, too, I might add) Ferris Bueller, if you have the means to pick up Visual Studio Team Edition or even Pro, I highly recommend it, but if you don't, don't let that stop you from getting started in .Net development.  Download Visual Studio Express, and get started today!