htaccess设置301重定向的方法:
打开.htaccess文件,加入以下规则,例如:
1.yisu.com重定向到www.yisu.com
RewriteEngine On
RewriteCond %{HTTP_HOST} ^yisu.com [NC]
RewriteRule ^(.*)$ http://www.yisu.com/$1 [L,R=301]
2.www.yisu.com重定向到yisu.com
RewriteEngine On
RewriteCond %{HTTP_HOST} !yisu.com$ [NC]
RewriteRule ^(.*)$ http://yisu.com/$1 [L,R=301]
3.oldyisu.com重定向到www.newyisu.com
RewriteEngine On
RewriteCond %{HTTP_HOST} !oldyisu.com$ [NC]
RewriteRule ^(.*)$ http://www.newyisu.com/$1 [L,R=301]
4.oldyisu.com重定向到newyisu.com
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} !oldyisu.com$ [NC]
RewriteRule ^(.*)$ http://newyisu.com/$1 [L,R=301]
5.yisu.com/file/file.php重定向到otheryisu.com/otherfile/other.php
RewriteCond %{HTTP_HOST} ^www.yisu.com$
RewriteRule ^file/file.php$ http://www.otheryisu.com/otherfile/other.php [R=301,L]