日期:2014-05-17  浏览次数:20698 次

apache 301重定向的设置方法
直接在.htaccess文件里设置,如下:
RewriteEngine on
RewriteCond %{HTTP_HOST} ^xn--ygvo0Mb46A.com [NC]
RewriteRule ^(.*)$ http://www.9qc.com/$1 [L,R=301]
RewriteCond %{HTTP_HOST} ^www.xn--ygvo0Mb46A.com [NC]
RewriteRule ^(.*)$ http://www.9qc.com/$1 [L,R=301]
这样,xn--ygvo0Mb46A.com这个顶级域名和www.xn--ygvo0Mb46A.com这个二级域名都重定向到www.9qc.com这个域名了.检测工具检测如下:

查询地址:http://www.xn--ygvo0mb46a.com/
返回状态码:301
网页返回HEAD信息如下
Date: Tue, 06 Jul 2010 10:24:00 GMT
Location: http://www.9qc.com/
Cache-Control: max-age=31104000
Expires: Fri, 01 Jul 2011 10:24:00 GMT
Vary: Accept-Encoding
Content-Length: 227
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: text/html; charset=iso-8859-1

查询地址:http://xn--ygvo0mb46a.com/
返回状态码:301
网页返回HEAD信息如下
Date: Tue, 06 Jul 2010 10:24:23 GMT
Location: http://www.9qc.com/
Cache-Control: max-age=31104000
Expires: Fri, 01 Jul 2011 10:24:23 GMT
Vary: Accept-Encoding
Content-Length: 227
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: text/html; charset=iso-8859-1

但是这个重定向好像不支持中文域名,比如 www.旧汽车.com ,这样做以后会显示302 .
交流更多 apache 301重定向的设置方法 ,去 www.9qc.com 看看.