Code:
Options +FollowSymlinks
RewriteEngine On
RewriteCond %{HTTP_HOST} !^(www\.|$) [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Directly from SitePoints topic about SEO with Google.
http://www.sitepoint.com/forums/showthread.php?t=356031
@Chaos: I hope you don't mean by yours that you coded it.