Redirect if domain is not correct
It's better to make 301 redirect in SEO purposes:
RewriteCond %{HTTP_HOST} ^www.example.com(.*)$ [NC]
RewriteRule ^(.*)$ http://example.com$1 [R=301,L]
You can do this with an If directive...
<If "%{HTTP_HOST} != 'www.example.com'">
Redirect / http://www.example.com/
</If>
Or mod_rewrite. See http://httpd.apache.org/docs/current/rewrite/remapping.html
RewriteCond %{HTTP_HOST} !^www\.example\.com [NC]
RewriteCond %{HTTP_HOST} !^$
RewriteRule ^/?(.*) http://www.example.com/$1 [L,R,NE]