例如访问域名 www.name1.com 跳转到www.name2.com

在虚拟主机中加入配置:

   
        RewriteEngine on
        RewriteCond %{HTTP_HOST} ^www.name1.com$
        RewriteRule ^(.*)$ http://www.name2.com/$1 [R=301,L]
   

 

多个域名跳转:

   
        RewriteEngine on
        RewriteCond %{HTTP_HOST} ^www.name.com [OR]
        RewriteCond %{HTTP_HOST} ^www.name1.com$
        RewriteRule ^(.*)$ http://www.name2.com/$1 [R=301,L]