使用htaccess做301跳转或302跳转

编辑.htaccess文件,不带www,301跳转到带www的域名:

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

旧域名1.com做301跳转到新域名2.com :

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

强帖留名: