$Is301 = 0; //301开关
if ($Is301==0){
$GetDomain = strtolower(“http://”.$_SERVER[‘SERVER_NAME’]); //获取当前域名
$NewDomain = “http://www.5yhua.org/yimin/bbs”; //转发至新的域名function NewUri(){
$StrUri = strtolower($_SERVER[‘REQUEST_URI’]); //将获取的动态URL转换为小写
$StrUri = str_replace(“/bbs/”,”/”,$StrUri); //替换”/bbs/”为”/”$StrUri = preg_replace(“~(.*)/forumdisplay\.php\?fid\=(\d+)\&page\=(\d+)\&~”, “$1/forum-$2-$3.html”, $StrUri);
$StrUri = preg_replace(“~(.*)/viewthread\.php\?tid\=(\d+)\&extra\=page\%3d(\d+)\&page\=(\d+)\&(\d+)~”, “$1/thread-$2-$4-$5.html”, $StrUri);
$StrUri = preg_replace(“~(.*)/space\.php\?(uid|username)\=(.*)\&~”, “$1/space-$2-$3.html”, $StrUri);
$StrUri = preg_replace(“~(.*)/tag\.php\?name\=([^&]+?)\&~”, “$1/tag-$2.html”, $StrUri);
$StrUri = preg_replace(“~(.*)/index\.php\?gid=(\d+)~”, “$1/index-gid-$2.html”, $StrUri);
$StrUri = preg_replace(“~(.*)/index\.php~”, “$1”, $StrUri);
$StrUri = preg_replace(“~(.*)/archiver/index.php\?(fid|tid)-(\d+)(.*)\.html\&~”, “$1/archiver/$2-$3$4.html”, $StrUri);return $StrUri;
}if($GetDomain != $NewDomain){
Header(“HTTP/1.1 301 Moved Permanently”);
Header(“Location: “. $NewDomain.NewUri());
exit();
}
}
由于Discuz 7系列的伪静态规则和连接规则和 X系列的不同,很多老链接直接无法访问,需要在 index.php文件的头部加上以上代码 可以让7系列的地址转换访问到x系列哦,无限星辰工作室 www.xmspace.net 整理发布,转载请注明作者 和地址 谢谢!