天空小小岛技术网站
标题:
网站换域名,IIS 的 rewrite 规则怎么弄?
[打印本页]
作者:
一粒米
时间:
2013-8-2 21:30
标题:
网站换域名,IIS 的 rewrite 规则怎么弄?
isapi_rewrite 版本 < 3
RewriteCond Host: ^old.tkxxd.net$
RewriteRule (.*) http://new\.tkxxd\.net$1 [IR]
复制代码
isapi_rewrite 3.x
RewriteCond %{HTTP:Host} ^old.tkxxd.net$
RewriteRule (.*) http://new\.tkxxd\.net$1 [NC,R=301]
复制代码
其他问题,参考官方文档
3.x 文档
http://www.helicontech.com/isapi_rewrite/doc/
2.x 文档
http://www.isapirewrite.com/docs/
====可爱的分隔线=====
PS:1.x跳转时代码是302,不能指定301。2.x 某些版本可以用 RP 来试一下是否支持发送301头部。
如果rewrite 只能用 302 跳,你却非要用301跳,而且伪静态要跳到伪静态
以 dz 为样例,config/config_global.php 里找到
$_config = array();
复制代码
在上面增加
if(in_array($_SERVER['HTTP_HOST'], array('old.tkxxd.net'))) {
header('HTTP/1.1 301 Moved Permanently');
header('Location: http://new.tkxxd.net'.$_SERVER['HTTP_X_REWRITE_URL']);
}
复制代码
需要注意的一点是 $_SERVER['REQUEST_URI'] 经过 rewrite 后,读到的地址是动态的,所以要跳伪静态,必须使用 $_SERVER['HTTP_X_REWRITE_URL']
欢迎光临 天空小小岛技术网站 (http://tkxxd.net/)
Powered by Discuz! X3.1