Redirect from one domain to another domain

RewriteCond %{HTTP_HOST} domain1.com
RewriteRule (.*) http://domain2.com/$1 [R=301,L]