Canonical - Auto to WWW - Apache

Configure Apache to automatically redirect requests to the WWW subdomain.

Code

RewriteCond %{HTTP_HOST} !^www.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]