There are many samples around this. But I find the following one if you’re parking many domains on the same hosting…
RewriteCond %{HTTP_HOST} !^www\. RewriteRule (.*) http://www.%{HTTP_HOST}/$1 [R=301,L] |
A very useful tutorial around .htaccess I found is here.
To suppress this use
[code]
RewriteCond %{HTTP_HOST} ^www.(.+)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
[/code]