Setting up a Primary URL

This post is more for my own reference as I always forget the syntax.

When you have several domains but want to have one of them set up as a primary I generally set up Apache like so:

<VirtualHost *:80>
ServerAlias * * *
DocumentRoot /var/www/domain/

Then in the root folder set up a .htaccess with the following:

Options +FollowSymlinks
RewriteEngine on
RewriteCond %{HTTP_HOST} !^www\.domain\.com$
RewriteRule ^(.*)$1 [L,R=301]