Here's what I'm looking to do:
if http://acme.com/ has nothing after the slash rewrite to http://www.acme.com/
if http://www.acme.com/ has nothing after the slash do not rewrite
if http://acme.com/ has stuff after the slash (http://acme.com/abc/def) then rewrite to http://www.foobar.com/abc/def
Thanks.
Check this answer on stackoverflow.com. I think it explains everything you need.