vi/usr/local/apache2/conf/extra/httpd-vhosts.conf
单域名跳转:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.domain1.com$
RewriteRule ^/(.*)$ http://www.domain2.com/$1 [R=301,L]
</IfModule>
如果是多个域名,可以这样设置:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.domain.com [OR]
RewriteCond %{HTTP_HOST} ^www.domain1.com$
RewriteRule ^/(.*)$ http://www.domain2.com/$1 [R=301,L]
</IfModule>
3个:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.domain.com[OR]
RewriteCond %{HTTP_HOST} ^www.domain1.com$
RewriteCond%{HTTP_HOST} ^www.domain3.com [OR]
RewriteRule ^/(.*)$ http://www.domain2.com/$1[R=301,L]
</IfModule>
(先可以这样写,后面多加个$)