1.9域名301跳转

一、将www.aaa.com跳转到www.test.com

<VirtualHost *:80>

    DocumentRoot "/data/www"

     ServerName www.test.com

     ServerAlias www.aaa.com

<IfModule mod_rewrite.c>

  RewriteEngine on

  RewriteCond %{HTTP_HOST} ^www.aaa.com$

  RewriteRule ^/(.*)$ http://www.test.com/$1 [R=301,L]

 </IfModule>

二、多个域名

<IfModule mod_rewrite.c>

  RewriteEngine on

  RewriteCond %{HTTP_HOST} ^www.aaa.com$  [OR]

RewriteCond %{HTTP_HOST} ^www.bbb.com$

  RewriteRule ^/(.*)$ http://www.test.com/$1 [R=301,L]

 </IfModule>

或者

<IfModule mod_rewrite.c>

  RewriteEngine on

  RewriteCond %{HTTP_HOST} !^www.test.com$

  RewriteRule ^/(.*)$ http://www.test.com/$1 [R=301,L]

 </IfModule>

#curl -x127.0.0.1:80 www.aaa.com      //快速测试跳转


你可能感兴趣的:(1.9域名301跳转)