Listen 111.111.111.111:80
Listen 222.222.222.222:80
Listen 222.222.222.222:443
NameVirtualHost 111.111.111.111:80
#Default for 222.222.222.222
ServerAlias domain.com www.domain.com domain.co.uk www.domain.co.uk
ServerName www.domain.com:80
ServerAlias domain.com www.domain.com domain.co.uk www.domain.co.uk
#Default for 111.111.111.111
ServerAlias foo.com www.foo.com
ServerName www.foo.com
#
# ServerAlias bar.com www.bar.com
#
This example has different names than in the channel but if you go to bar.com foo.com shows. What I want to happen is it to redirect to domain.com. The rewrite rule just doesnt want to redirect to a different domain altogether.
In practice the rewrite rule would be...
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www.domain.com$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [R,L]
This would be in a .htaccess file in the / for foo.com