宜昌本地软件开发与弱电工程服务商
项目咨询 · 快速响应

[apache]apache下301重定向的设置

2016-10-13 00:16:48 点击量:13 标签: 收藏本文

直接在.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