织梦电脑站手机站伪静态+全套伪静态规则-固定目录版
寫在前面的話
- 請(qǐng)確保你網(wǎng)站所在的主機(jī)或者服務(wù)器支持偽靜態(tài)并且已經(jīng)開啟了偽靜態(tài)功能
- 本教程只適合給那些需要電腦版和手機(jī)版都想要偽靜態(tài)的小伙伴使用!
設(shè)置偽靜態(tài)后,你的電腦站url會(huì)像如下
- 列表頁??? http://www.dedehtml.com/plus/list-2.html
- 列表頁分頁? http://www.dedehtml.com/plus/list-2-26-2.html
- 內(nèi)容頁??? http://www.dedehtml.com/plus/view-112-1.html
- 內(nèi)容頁分頁? http://www.dedehtml.com/plus/view-112-2.html
- TAG標(biāo)簽頁? http://www.dedehtml.com/tags/織夢(mèng)/
- TAG標(biāo)簽分頁 http://www.dedehtml.com/tags/織夢(mèng)/2/
- 搜索頁??? http://www.dedehtml.com/search/織夢(mèng).html
- 搜索頁分頁? http://www.dedehtml.com/search/織夢(mèng)-2.html
設(shè)置偽靜態(tài)后,你的手機(jī)站url會(huì)像如下
- 列表頁??? http://m.dedehtml.com/plus/list-2.html
- 列表頁分頁? http://m.dedehtml.com/plus/list-2-26-2.html
- 內(nèi)容頁??? http://m.dedehtml.com/plus/view-112-1.html
- 內(nèi)容頁分頁? http://m.dedehtml.com/plus/view-112-2.html
- TAG標(biāo)簽頁? http://m.dedehtml.com/tags/織夢(mèng)/
- TAG標(biāo)簽分頁 http://m.dedehtml.com/tags/織夢(mèng)/2/
- 搜索頁??? http://m.dedehtml.com/search/織夢(mèng).html
- 搜索頁分頁? http://m.dedehtml.com/search/織夢(mèng)-2.html
1、網(wǎng)站后臺(tái)開啟偽靜態(tài)
后臺(tái)-系統(tǒng)參數(shù)-核心設(shè)置-是否使用偽靜態(tài):"是"
2、網(wǎng)站后臺(tái)取消絕對(duì)路徑
后臺(tái)-系統(tǒng)配置-啟用絕對(duì)網(wǎng)址 改成 【否】,不用擔(dān)心手機(jī)站圖片問題,下面手機(jī)站偽靜態(tài)教程里有辦法
3、網(wǎng)站后臺(tái)設(shè)置整站為動(dòng)態(tài)
這里可以借助我寫的一個(gè)小插件來完成,一勞永逸
織夢(mèng)全站動(dòng)態(tài)靜態(tài)一鍵切換插件
電腦站偽靜態(tài)教程開始
1、列表頁和內(nèi)容頁偽靜態(tài)鏈接
打開 /include/helpers/channelunit.helper.php 找到
global $cfg_typedir_df;改成
global $cfg_typedir_df, $cfg_rewrite;繼續(xù)找到
$reurl = $GLOBALS['cfg_phpurl']."/list.php?tid=".$typeid;改成
if($cfg_rewrite == 'Y') {$reurl = $GLOBALS["cfg_phpurl"]."/list-".$typeid.'.html'; } else {//動(dòng)態(tài)$reurl = $GLOBALS['cfg_phpurl']."/list.php?tid=".$typeid; }2、TAG標(biāo)簽偽靜態(tài)鏈接
打開 /include/taglib/tag.lib.php 找到
$row['link'] = $cfg_cmsurl."/tags.php?/".urlencode($row['keyword'])."/";改成
$row['link'] = $cfg_cmsurl."/tags/".urlencode($row['keyword'])."/";3、TAG標(biāo)簽分頁偽靜態(tài)鏈接
打開 /include/arc.taglist.class.php 找到
$this->PageNo = $GLOBALS['PageNo'];在它的下面加入
if($this->PageNo == 0) {$this->PageNo = 1; }繼續(xù)找到
$prepage="";在它的上面加入
global $cfg_rewrite;繼續(xù)找到
$purl .= "?/".urlencode($this->Tag);改成
if($cfg_rewrite == 'Y') {$purl = "/tags/".urlencode($this->Tag); } else {$purl .= "?/".urlencode($this->Tag); }4、搜索頁偽靜態(tài)鏈接
打開 /plus/search.php 找到
$mid = (isset($mid) && is_numeric($mid)) ? $mid : 0;在它的下面加入
if ( $mobile==1 ) {define('DEDEMOB', 'Y'); }繼續(xù)找到
$t1 = ExecTime();在它的下面加入
$keyword = preg_replace("/-(\d+)/i",'',$keyword); $oldkeyword = preg_replace("/-(\d+)/i",'',$oldkeyword);打開 /include/arc.searchview.class.php 找到
global $oldkeyword;改成
global $oldkeyword, $cfg_rewrite;繼續(xù)找到
$purl .= "?".$geturl;改成
if($cfg_rewrite != 'Y' && !defined('DEDEMOB')) {$purl .= "?".$geturl; } else {$purl = '/search/'.urlencode($oldkeyword); }繼續(xù)找到
return $plist;改成
if($cfg_rewrite == 'Y') {$plist = preg_replace("/PageNo=(\d+)/i",'-\\1.html',$plist); } return $plist;還需要在你電腦站模板里把搜索框代碼改成靜態(tài)的js提交搜索,參考下面代碼,注意標(biāo)紅的地方
<script type="text/javascript">
function search()
{
?? ?var q = document.getElementById("q").value;
?? ?window.location.href = "http://www.dedediy.com/search/"+q+".html";
}
function enterIn(obj,evt)
{
?? ?var evt = evt ? evt : (window.event ? window.event : null);
?? ?if (evt.keyCode == 13)
?? ?{
?? ??? ?var q = obj.value;
?? ??? ?window.location.href = "http://www.dedediy.com/search/"+q+".html";
?? ?}
}
</script>
<form action="" method="post" οnsubmit="return false">
?? ?<div class="form">
?? ??? ?<h4>搜索</h4>
?? ??? ?<input name="q" id="q" οnkeydοwn="enterIn(this,event);" type="text" />
?? ??? ?<button type="submit" class="search-submit" οnclick="search()">搜索</button>
?? ?</div>
</form>
電腦站偽靜態(tài)規(guī)則文件打包下載
鏈接: https://pan.baidu.com/s/1sVpMusrJ1Zg8quZ5xq3UpQ 密碼: 5t29
包括iis6、iis7、8、apache、nginx,下載后選擇對(duì)應(yīng)的偽靜態(tài)規(guī)則文件
手機(jī)版?zhèn)戊o態(tài)教程開始
1.移動(dòng)版域名 m.dedehtml.com 解析并指向和綁定目錄到網(wǎng)站目錄的m文件夾
2.后臺(tái)-系統(tǒng)配置 添加變量
(為了使用絕對(duì)路徑,使用電腦版的文章圖片,為了移動(dòng)版模板css、js、images使用絕對(duì)路徑)
變量名稱:cfg_mobile
變量類型:文本
參數(shù)說明:手機(jī)版網(wǎng)址
變量值:http://m.123.com
所屬組:站點(diǎn)設(shè)置
變量名稱:cfg_rewritem
變量類型:布爾(Y/N)
參數(shù)說明:手機(jī)版?zhèn)戊o態(tài)
變量值:Y
所屬組:站點(diǎn)設(shè)置
3.移動(dòng)版當(dāng)前位置 {dede:field.position/} 標(biāo)簽動(dòng)態(tài)改成偽靜態(tài)
打開 /include/typelink.class.php 找到
$indexpage = "<a href='index.php'>".$this->indexName."</a>";改成
if($GLOBALS['cfg_rewritem'] == 'Y') {$indexpage = "<a href='".$GLOBALS['cfg_mobile']."'>".$this->indexName."</a>"; } else {$indexpage = "<a href='index.php'>".$this->indexName."</a>"; }繼續(xù)找到
return 'list.php?tid='.$typeinfos['id'];改成
if($GLOBALS['cfg_rewritem'] == 'Y') {return GetTypeUrl($typeinfos['id'],MfTypedir($typeinfos['typedir']),$typeinfos['isdefault'],$typeinfos['defaultname'],$typeinfos['ispart'],$typeinfos['namerule2'],$typeinfos['moresite'],$typeinfos['siteurl'],$typeinfos['sitepath']); } else {return 'list.php?tid='.$typeinfos['id']; }4.設(shè)置手機(jī)站首頁不生成index.html,即永遠(yuǎn)是動(dòng)態(tài)
打開 /m/index.php 找到
$row['showmod'] == 1改成
$row['showmod'] == 10如果m文件夾里有index.html,記得刪除一下
5.手機(jī)站偽靜態(tài)規(guī)則文件打包下載
鏈接: https://pan.baidu.com/s/1sVpMusrJ1Zg8quZ5xq3UpQ 密碼: 5t29
包括iis6、iis7、8、apache、nginx,下載后選擇對(duì)應(yīng)的偽靜態(tài)規(guī)則文件
6.手機(jī)版m文件夾下添加 search.php 和 tags.php
用于手機(jī)版的搜索頁和標(biāo)簽頁,也別忘記他們的模板哦 search_m.htm tag_m.htm taglist_m.htm
鏈接: https://pan.baidu.com/s/1-adTGXzVWGH4x3LX8VdL5w 密碼: w2z6
7.把所有手機(jī)版模板文件_m.htm 結(jié)尾的,把模板里面的代碼都改成電腦版
還有幾個(gè)特別的,請(qǐng)認(rèn)真對(duì)比下面
css、js、images 改成絕對(duì)路徑,例如 assets/css/ 改成 /assets/css/
index.php 改成 {dede:global.cfg_mobile/}
list.php?tid=[field:id/] 改成 [field:typelink/]
list.php?tid=~id~ 改成 ~typelink~
list.php?tid={dede:field name='id'/} 改成 {dede:field.typeurl/}
view.php?aid=[field:id/] 改成 [field:arcurl/]
[field:litpic/] 改成 [field:global.cfg_basehost/][field:litpic/]
[field:image/] 改成 <img src="[field:global.cfg_basehost/][field:litpic/]">
上一頁標(biāo)簽 {dede:prenext get='pre'/}
改成
{dede:prenext get=pre runphp=yes}
$preurl = @me;
preg_match('/aid=(\d*)/',$preurl,$match);
$result = GetOneArchive($match[1]);
@me = !empty($result) ? "上一篇:<a href=\"{$result['arcurl']}\">{$result['title']}</a>" : "上一篇:沒有了";
{/dede:prenext}
下一頁標(biāo)簽 {dede:prenext get='next'/}
改成
{dede:prenext get=next runphp=yes}
$preurl = @me;
preg_match('/aid=(\d*)/',$preurl,$match);
$result = GetOneArchive($match[1]);
@me = !empty($result) ? "下一篇:<a href=\"{$result['arcurl']}\">{$result['title']}</a>" : "下一篇:沒有了";
{/dede:prenext}
文章內(nèi)容 {dede:field.body/}
{dede:field.body runphp=yes}
global $cfg_basehost;
$str = @me;
$search = '/(<img.*?)width=(["\'])?.*?(?(2)\2|\s)([^>]+>)/is';
$search1 = '/(<img.*?)height=(["\'])?.*?(?(2)\2|\s)([^>]+>)/is';
$search2 = '#(<img.*?style=".*?)width:\d+px;([^"]*?.*?>)#i';
$search3 = '#(<img.*?style=".*?)height:\d+px;([^"]*?.*?>)#i';
$content = preg_replace($search,'$1$3',$str);
$content = preg_replace($search1,'$1$3',$content);
$content = preg_replace($search2,'$1$2',$content);
$content = preg_replace($search3,'$1$2',$content);
@me = $content;
@me = str_replace('https://www.dedehtml.com/uploads/allimg/', $cfg_basehost.'https://www.dedehtml.com/uploads/allimg/', $content);
{/dede:field.body}
欄目內(nèi)容 {dede:field.content/}
改成
{dede:field.content runphp=yes}
global $cfg_basehost;
$str = @me;
$search = '/(<img.*?)width=(["\'])?.*?(?(2)\2|\s)([^>]+>)/is';
$search1 = '/(<img.*?)height=(["\'])?.*?(?(2)\2|\s)([^>]+>)/is';
$search2 = '#(<img.*?style=".*?)width:\d+px;([^"]*?.*?>)#i';
$search3 = '#(<img.*?style=".*?)height:\d+px;([^"]*?.*?>)#i';
$content = preg_replace($search,'$1$3',$str);
$content = preg_replace($search1,'$1$3',$content);
$content = preg_replace($search2,'$1$2',$content);
$content = preg_replace($search3,'$1$2',$content);
@me = $content;
@me = str_replace('https://www.dedehtml.com/uploads/allimg/', $cfg_basehost.'https://www.dedehtml.com/uploads/allimg/', $content);
{/dede:field.content}
搜索框代碼改成靜態(tài)的js提交搜索,參考下面代碼,注意標(biāo)紅的地方
<script type="text/javascript">
function search()
{
?? ?var q = document.getElementById("q").value;
?? ?window.location.href = "http://m.dedediy.com/search/"+q+".html";
}
function enterIn(obj,evt)
{
?? ?var evt = evt ? evt : (window.event ? window.event : null);
?? ?if (evt.keyCode == 13)
?? ?{
?? ??? ?var q = obj.value;
?? ??? ?window.location.href = "http://m.dedediy.com/search/"+q+".html";
?? ?}
}
</script>
<form action="" method="post" οnsubmit="return false">
?? ?<div class="form">
?? ??? ?<h4>搜索</h4>
?? ??? ?<input name="q" id="q" οnkeydοwn="enterIn(this,event);" type="text" />
?? ??? ?<button type="submit" class="search-submit" οnclick="search()">搜索</button>
?? ?</div>
</form>
電腦版跳轉(zhuǎn)到移動(dòng)版代碼
1)首頁
<meta http-equiv="mobile-agent" content="format=xhtml;url={dede:global.cfg_mobile/}"> <script type="text/javascript">if(window.location.toString().indexOf('pref=padindex') != -1){}else{if(/AppleWebKit.*Mobile/i.test(navigator.userAgent) || (/MIDP|SymbianOS|NOKIA|SAMSUNG|LG|NEC|TCL|Alcatel|BIRD|DBTEL|Dopod|PHILIPS|HAIER|LENOVO|MOT-|Nokia|SonyEricsson|SIE-|Amoi|ZTE/.test(navigator.userAgent))){if(window.location.href.indexOf("?mobile")<0){try{if(/Android|Windows Phone|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)){window.location.href="{dede:global.cfg_mobile/}";}else if(/iPad/i.test(navigator.userAgent)){}else{}}catch(e){}}}}</script>2)列表
<meta http-equiv="mobile-agent" content="format=xhtml;url={dede:global.cfg_mobile/}{dede:type}[field:typeurl/]{/dede:type}"> <script type="text/javascript">if(window.location.toString().indexOf('pref=padindex') != -1){}else{if(/AppleWebKit.*Mobile/i.test(navigator.userAgent) || (/MIDP|SymbianOS|NOKIA|SAMSUNG|LG|NEC|TCL|Alcatel|BIRD|DBTEL|Dopod|PHILIPS|HAIER|LENOVO|MOT-|Nokia|SonyEricsson|SIE-|Amoi|ZTE/.test(navigator.userAgent))){if(window.location.href.indexOf("?mobile")<0){try{if(/Android|Windows Phone|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)){window.location.href="{dede:global.cfg_mobile/}{dede:type}[field:typeurl/]{/dede:type}";}else if(/iPad/i.test(navigator.userAgent)){}else{}}catch(e){}}}}</script>3)內(nèi)容
<meta http-equiv="mobile-agent" content="format=xhtml;url={dede:global.cfg_mobile/}{dede:field.id runphp=yes}$result=GetOneArchive(@me);@me=$result['arcurl'];{/dede:field.id}"> <script type="text/javascript">if(window.location.toString().indexOf('pref=padindex') != -1){}else{if(/AppleWebKit.*Mobile/i.test(navigator.userAgent) || (/MIDP|SymbianOS|NOKIA|SAMSUNG|LG|NEC|TCL|Alcatel|BIRD|DBTEL|Dopod|PHILIPS|HAIER|LENOVO|MOT-|Nokia|SonyEricsson|SIE-|Amoi|ZTE/.test(navigator.userAgent))){if(window.location.href.indexOf("?mobile")<0){try{if(/Android|Windows Phone|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)){window.location.href="{dede:global.cfg_mobile/}{dede:field.id runphp=yes}$result=GetOneArchive(@me);@me=$result['arcurl'];{/dede:field.id}";}else if(/iPad/i.test(navigator.userAgent)){}else{}}catch(e){}}}}</script>轉(zhuǎn)載于:https://www.cnblogs.com/dedehtml/p/9913853.html
總結(jié)
以上是生活随笔為你收集整理的织梦电脑站手机站伪静态+全套伪静态规则-固定目录版的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: AHS of FCGRC 停课 Day
- 下一篇: JS回到顶部