If I go to http://www.example.com I want it to stay there, which is working fine.
If I go to http://bar.example.com it redirects to http://www..com, which is wrong
I want it to go to http://www.example.com given the backreference in the RewriteCond
RewriteEngine On
RewriteCond %{HTTP_HOST} !^$
RewriteCond %{HTTP_HOST} !^www.(example).com [NC]
RewriteRule ^(.*) http://www.%1.com/$1 [L,R]
Ubuntu 8.04
Package: apache2-mpm-prefork
Architecture: i386
Version: 2.2.8-1