Inside the .htaccess add this:
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
Just after
RewriteEngine On
Only works with Apache. You'd have to google a solution for Nginx yourself as you probably also had to set up the vhost for Nginx yourself ?