五月综合缴情婷婷六月,色94色欧美sute亚洲线路二,日韩制服国产精品一区,色噜噜一区二区三区,香港三级午夜理伦三级三

您現(xiàn)在的位置: 365建站網(wǎng) > 365文章 > Discuz! X3.4 SEO手機偽靜態(tài)設(shè)置原理和方法

Discuz! X3.4 SEO手機偽靜態(tài)設(shè)置原理和方法

文章來源:365jz.com     點擊數(shù):1893    更新時間:2020-07-18 12:06   參與評論

Discuz! X3.4 SEO手機偽靜態(tài)設(shè)置原理和方法:

實現(xiàn)Discuz手機觸屏版?zhèn)戊o態(tài),統(tǒng)一PC端和手機觸屏版的訪問地址,有利于手機版的SEO優(yōu)化,方便搜索引擎移動端適配,提升站點移動端收錄量(移動端搜素已超越PC端搜索)實現(xiàn)Discuz手機觸屏版?zhèn)戊o態(tài),統(tǒng)一PC端和手機觸屏版的訪問地址,有利于手機版的SEO優(yōu)化,方便搜索引擎移動端適配,提升站點移動端收錄量(移動端搜素已超越PC端搜索)

通過查找,發(fā)現(xiàn)電腦版設(shè)置偽靜態(tài)的方法

1,通過后臺設(shè)置seo選項

image.png

規(guī)則如下:

[ISAPI_Rewrite]

# 3600 = 1 hour
CacheClockRate 3600

RepeatLimit 32

# Protect httpd.ini and httpd.parse.errors files
# from accessing through HTTP
RewriteRule ^(.*)/topic-(.+)\.html(\?(.*))*$ $1/portal\.php\?mod=topic&topic=$2&$4
RewriteRule ^(.*)/article-([0-9]+)-([0-9]+)\.html(\?(.*))*$ $1/portal\.php\?mod=view&aid=$2&page=$3&$5
RewriteRule ^(.*)/forum-(\w+)-([0-9]+)\.html(\?(.*))*$ $1/forum\.php\?mod=forumdisplay&fid=$2&page=$3&$5
RewriteRule ^(.*)/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html(\?(.*))*$ $1/forum\.php\?mod=viewthread&tid=$2&extra=page\%3D$4&page=$3&$6
RewriteRule ^(.*)/group-([0-9]+)-([0-9]+)\.html(\?(.*))*$ $1/forum\.php\?mod=group&fid=$2&page=$3&$5
RewriteRule ^(.*)/space-(username|uid)-(.+)\.html(\?(.*))*$ $1/home\.php\?mod=space&$2=$3&$5
RewriteRule ^(.*)/blog-([0-9]+)-([0-9]+)\.html(\?(.*))*$ $1/home\.php\?mod=space&uid=$2&do=blog&id=$3&$5
RewriteRule ^(.*)/(fid|tid)-([0-9]+)\.html(\?(.*))*$ $1/archiver/index\.php\?action=$2&value=$3&$5


然后找到source/function/function_core.php中的函數(shù)

function rewriteoutput($type, $returntype, $host) {
	global $_G;
	$fextra = '';
	if($type == 'forum_forumdisplay') {
		list(,,, $fid, $page, $extra) = func_get_args();
		$r = array(
			'{fid}' => empty($_G['setting']['forumkeys'][$fid]) ? $fid : $_G['setting']['forumkeys'][$fid],
			'{page}' => $page ? $page : 1,
		);
	} elseif($type == 'forum_viewthread') {
		list(,,, $tid, $page, $prevpage, $extra) = func_get_args();
		$r = array(
			'{tid}' => $tid,
			'{page}' => $page ? $page : 1,
			'{prevpage}' => $prevpage && !IS_ROBOT ? $prevpage : 1,
		);
	} elseif($type == 'home_space') {
		list(,,, $uid, $username, $extra) = func_get_args();
		$_G['setting']['rewritecompatible'] && $username = rawurlencode($username);
		$r = array(
			'{user}' => $uid ? 'uid' : 'username',
			'{value}' => $uid ? $uid : $username,
		);
	} elseif($type == 'home_blog') {
		list(,,, $uid, $blogid, $extra) = func_get_args();
		$r = array(
			'{uid}' => $uid,
			'{blogid}' => $blogid,
		);
	} elseif($type == 'group_group') {
		list(,,, $fid, $page, $extra) = func_get_args();
		$r = array(
			'{fid}' => $fid,
			'{page}' => $page ? $page : 1,
		);
	} elseif($type == 'portal_topic') {
		list(,,, $name, $extra) = func_get_args();
		$r = array(
			'{name}' => $name,
		);
	} elseif($type == 'portal_article') {
		list(,,, $id, $page, $extra) = func_get_args();
		$r = array(
			'{id}' => $id,
			'{page}' => $page ? $page : 1,
		);
	} elseif($type == 'forum_archiver') {
		list(,, $action, $value, $page, $extra) = func_get_args();
		$host = '';
		$r = array(
			'{action}' => $action,
			'{value}' => $value,
		);
		if($page) {
			$fextra = '?page='.$page;
		}
	} elseif($type == 'plugin') {
		list(,, $pluginid, $module,, $param, $extra) = func_get_args();
		$host = '';
		$r = array(
			'{pluginid}' => $pluginid,
			'{module}' => $module,
		);
		if($param) {
			$fextra = '?'.$param;
		}
	}
	$href = str_replace(array_keys($r), $r, $_G['setting']['rewriterule'][$type]).$fextra;
	if(!$returntype) {
		return '<a href="'.$host.$href.'"'.(!empty($extra) ? stripslashes($extra) : '').'>';
	} else {
		return $host.$href;
	}
}

這是實現(xiàn)電腦版?zhèn)戊o態(tài)的處理函數(shù)


在移動版中,找到source\class\helper\helper_mobile.php中的函數(shù) mobilereplace,修改成如下所示:

public static function mobilereplace($file, $replace) {
if(strpos($replace, 'mobile=') === false) {
if(strpos($replace, '?') === false) {
$replace = 'href="'.$file.$replace.'?mobile='.IN_MOBILE.'"';
} else {
$replace = 'href="'.$file.$replace.'&amp;mobile='.IN_MOBILE.'"';
//$replace=str_replace('&amp;mobile=2','',$replace);
$replace=mbrewriteoutput($replace);
}
return $replace;
} else {
return 'href="'.$file.$replace.'"';
}
}

然后在source/function/function_core.php中增加函數(shù)

function mbrewriteoutput($eurl) {
		if(strstr($eurl,"forum.php?mod=forumdisplay&amp;fid=")){
	        $eurl=str_replace('&amp;mobile=2','',$eurl);
			$fidarr=explode("fid=",$eurl);
			$fid=$fidarr[1];
			$fid=str_replace('"','',$fid);
			$eurl=str_replace('forum.php?mod=forumdisplay&amp;fid='.$fid,'forum-'.$fid.'-1.html',$eurl);
			$eurl=str_replace('forum.php?mod=forumdisplay&fid='.$fid,'forum-'.$fid.'-1.html',$eurl);
			return $eurl;
		}elseif(strstr($eurl,"forum.php?mod=viewthread&amp;tid=")){
			$eurl=str_replace('&amp;extra=page%3D1&amp;mobile=2','',$eurl);
			$tidarr=explode("tid=",$eurl);
			$tid=$tidarr[1];
			$tid=str_replace('"','',$tid);
			$eurl=str_replace('forum.php?mod=viewthread&amp;tid='.$tid,'thread-'.$tid.'-1-1.html',$eurl);
			$eurl=str_replace('forum.php?mod=viewthread&amp;tid='.$tid,'thread-'.$tid.'-1-1.html',$eurl);
			return $eurl;
		}elseif(strstr($eurl,"forum.php?forumlist=1&amp;mobile=2")){
			$eurl=str_replace('forum.php?forumlist=1&amp;mobile=2','https://bbs.365jz.com/',$eurl);
			return $eurl;
		}
		return $eurl;
}

這樣就可以實現(xiàn)手機偽靜態(tài)

如對本文有疑問,請?zhí)峤坏浇涣髡搲?,廣大熱心網(wǎng)友會為你解答??! 點擊進入論壇

發(fā)表評論 (1893人查看0條評論)
請自覺遵守互聯(lián)網(wǎng)相關(guān)的政策法規(guī),嚴禁發(fā)布色情、暴力、反動的言論。
昵稱:
最新評論
2020年10月29日 17:12suchang888

你好 這個是IIS 的吧
Nginx應(yīng)該怎么寫

------分隔線----------------------------

其它欄目

· 建站教程
· 365學(xué)習(xí)

業(yè)務(wù)咨詢

· 技術(shù)支持
· 服務(wù)時間:9:00-18:00
365建站網(wǎng)二維碼

Powered by 365建站網(wǎng) RSS地圖 HTML地圖

copyright © 2013-2024 版權(quán)所有 鄂ICP備17013400號