Your original rewrite rule likely confused things because the $1 pattern that matched already had a '/' in it, thus you created a double slash. What happens if you use:
RewriteRule ^(.*)$ http://www.domain.com$1 [QSA,L,R=301]
and remove your extra rule?
UPDATE 1
You have misinterpreted what I meant. I wasn't talking about your workaround, but the original rule.
To make it more obvious what you are doing wrong and which is potentially causing issues, use:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^domain\.com$ [NC]
RewriteRule ^/(.*)$ http://www.domain.com/$1 [L,R=301]
Note how I have explicitly listed the '/' outside of the sub pattern. Only by doing that would it be okay to use a '/' before '$1'. If you don't you will get repeating slashes.
I'd also suggest dropping QSA. Examples I see elsewhere on the Internet don't use that either.
Finally, you should escape the '.' in the host name being matched else could technically match stuff other than a literal '.' as well.
So, try that. If still issues, then you should enable rewrite module logging and see what is going on. You possibly have some other rewrite rules in your configuration which are causing issues.
UPDATE 2
Hmmm, finally realised your actual problem is that you have the rewrite rule inside of the Directory directive container instead of outside.
So, move the rewrite rules to immediately inside of the VirtualHost and not the Directory directive.
Awesome! A good answer was given by anonymouse in a comment to the post:
Have you tried opening the site directly from the host to rule out any funky dns issues? I.E., add an entry for www.domain.com and domain.com to /etc/hosts and then open the site with links from a command prompt. If you've setup a separate virtualhost (non wordpress site) and you're still getting redirected back to domain.com then i would be suspect of Via: 1.1 ISA in the http headers. A quick search reveals Microsoft Internet Security & Acceleration Server. A reverse proxy and caching server among other things. It could be causing problems
The problem was (well, is) the ISA server. I still have no idea why this happens since I don't run that server, but adding both hosts to /etc/hosts and locally doing a wget -S on it gave me the proper behavior.
I'll need to talk to the people running that server to see if they know what it's about, but at least that explains why I couldn't get any sense out of what was happening.
Edit:
Fixed! Changing the "To" rule site name in the ISA server rule fixed it, even though link translation was off.
Best Answer
Set up multiple
<VirtualHost>
s in Apache, and point each one to a differentDocumentRoot
.