#enable rewrite module with: sudo a2enmod rewrite
#ad this to your VirtualHost config or /.htacess file
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^www.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
#restart apache: /etc/init.d/apache2 restart