This is a pretty simple use of mod_rewrite to force the use www in your urls.
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.example\.com$ [NC]
RewriteRule .? http://www.example.com%{REQUEST_URI} [R=301,L]\
The first line is only needed if mod_rewrite isn’t enabled on your server (though the module does need to be enabled). Replace example.com with your actual domain name of course.
No related posts.
Related posts brought to you by Yet Another Related Posts Plugin.

I have this one too.
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www.example.com$
RewriteRule ^(.*)$ http://www.example.com/$1 [R=301]
I think you have to be careful with HTTPS though because if you access https://example.com/securepage you’re going to get http://www.example.com/securepage
I used to use the one I posted above all the time. I haven’t tried it recently but it doesn’t work on Mosso/Rackspace Cloud. The one in the post does.