So we've set up an IP address for each domain on our server. What happens when our client supplies us with a giant list of 30 domains that may point to this IP and may or may not change/be wrong etc? Urgh. I wanted the other domains to redirect to the primary domain so there's not duplicate content across 30 sites.
192.168.1.1 is the local IP and 100.100.100.100 is the IP for the outside world.
<VirtualHost 192.168.1.1:80>
DocumentRoot /var/www/example.com
ServerName www.example.com
ServerAlias *
RewriteEngine On
RewriteCond %{HTTP_HOST} ^(.*)$ [NC]
RewriteCond %{HTTP_HOST} !^www\.example\.com$
RewriteCond %{HTTP_HOST} !^100\.100\.100\.100$
RewriteRule ^(.*)$ http://www.example.com$1 [L,R=301]
</VirtualHost>
This will redirect any requests to the IP that are not via "www.example.com" or "100.100.100.100" with a 301 to "example.com"