织梦DEDECMS5.7sp2全站目录化伪静态设置
类别:建站知识   时间:10-13

最新织梦DEDECMS全站目录化伪静态设置,伪静态设置成功后,网址和生成静态地址一样、电脑和手机访问地址也一样。

如果你电脑端是生成静态而手机端是动态的话,请查看织梦手机端伪静态设置http://www.ebandao.cn/1157.html

此教程适合文章命名选择的是{aid},如果你的文章命名选择的是{pinying},请看织梦DEDECMS全站伪静态(电脑+手机移动){pinyin}拼音版https://www.ebandao.cn/2506.html

伪静态设置成功后,访问URL地址效果如下。

电脑端的URL地址:

列表页  http://www.ebandao.cn/news/

列表分页 http://www.ebandao.cn/news/list_1_2.html

内容页    http://www.ebandao.cn/xinwenzixun/6.html

内容页分页  http://www.ebandao.cn/news/6_2.html

TAG标签页  http://www.ebandao.cn/tags/职场/

TAG标签分页 http://www.ebandao.cn/tags/职场/2/

搜索页    http://www.ebandao.cn/search/职场.html

搜索页分页  http://www.ebandao.cn/search/职场-2.html

手机端的URL地址:

列表页        http://m.ebandao.cn/news/

列表分页       http://m.ebandao.cn/news/list_1_2.html

内容页    http://m.ebandao.cn/news/6.html

内容页分页  http://m.ebandao.cn/xinwenzixun/6_2.html

TAG标签页  http://m.ebandao.cn/tags/职场/

TAG标签分页 http://m.ebandao.cn/tags/职场/2/

搜索页    http://m.ebandao.cn/search/职场.html

搜索页分页  http://m.ebandao.cn/search/职场-2.htm

网站后台设置:

一、后台-系统参数-核心设置-开启伪静态

1

核心设置里面,启用绝对网址关闭

2

二、安装全站动静态插件,下载的压缩包里有。设置全站为动态。

3

三、后台添加两个新变量:

变量名称:cfg_mobile

变量类型:文本

参数说明:手机版网址

变量值:http://m.ebandao.cn

所属组:站点设置

4

变量名称:cfg_rewritem

变量类型:布尔(Y/N)

参数说明:手机版伪静态

变量值:Y

所属组:站点设置

5

6

四、修改文件

1、列表页和内容页伪静态链接

打开 /plus/list.php 搜索

$tid = (isset($tid) && is_numeric($tid) ? $tid : 0);

修改为

if($cfg_rewrite == 'Y') { if(!is_numeric($tid)) { $typedir = parse_url($tid, PHP_URL_PATH); $PageNo = stripos(GetCurUrl(), '.html') ? intval(str_replace('.html', '', end(explode("_", GetCurUrl())))) : 1; $tinfos = $dsql->GetOne("SELECT * FROM `#@__arctype` WHERE typedir='/$typedir' or typedir='{cmspath}/$typedir'"); if(is_array($tinfos)) { $tid = $tinfos['id']; $typeid = GetSonIds($tid); $row = $dsql->GetOne("Select count(id) as total From `#@__archives` where typeid in({$typeid})"); } else { $tid = 0; } } } else { $tid = (isset($tid) && is_numeric($tid) ? $tid : 0); }

打开 /plus/view.php 搜索

$t1 = ExecTime();

在它下面加入

if($cfg_rewrite == 'Y') { if(!is_numeric($aid)) { $aid = stripos(GetCurUrl(), '.html') ? str_replace('.html', '', end(explode("/", GetCurUrl()))) : 0; $aidpage = explode("_",$aid); $aid = intval($aidpage[0]); $pageno = intval($aidpage[1]); } }

打开 /include/arc.listview.class.php 搜索

//获得上一页和下一页的链接

在它上面加入

if($cfg_rewrite == 'Y') { $purl = ""; } else { $geturl = "tid=".$this->TypeID."&TotalResult=".$this->TotalResult."&"; $purl .= '?'.$geturl; }

继续搜索

$plist = str_replace('.php?tid=', '-', $plist);

在它上面加上

$tnamerule = $this->GetMakeFileRule($this->Fields['id'],"list",$this->Fields['typedir'],$this->Fields['defaultname'],$this->Fields['namerule2']); $tnamerule = preg_replace("/^(.*)\//", '', $tnamerule); $plist = preg_replace("/PageNo=(\d+)/i",str_replace("{page}","\\1",$tnamerule),$plist);

打开 /include/helpers/channelunit.helper.php 搜索

global $cfg_typedir_df;

修改为

global $cfg_typedir_df, $cfg_rewrite;

继续搜索

$reurl = $GLOBALS['cfg_phpurl']."/list.php?tid=".$typeid;

修改为

if($cfg_rewrite == 'Y') { $reurl = $typedir.'/'; } else { //动态 $reurl = $GLOBALS['cfg_phpurl']."/list.php?tid=".$typeid; }

继续搜索

return $GLOBALS["cfg_plus_dir"]."/view-".$aid.'-1.html';

修改为

$articleDir = MfTypedir($typedir); $articleRule = strtolower($namerule); if($articleRule=='') { $articleRule = strtolower($GLOBALS['cfg_df_namerule']); } if($typedir=='') { $articleDir = $GLOBALS['cfg_cmspath'].$GLOBALS['cfg_arcdir']; } $dtime = GetDateMk($timetag); list($y, $m, $d) = explode('-', $dtime); $arr_rpsource = array('{typedir}','{y}','{m}','{d}','{timestamp}','{aid}','{cc}'); $arr_rpvalues = array($articleDir,$y, $m, $d, $timetag, $aid, dd2char($m.$d.$aid.$y)); if($filename != '') { $articleRule = dirname($articleRule).'/'.$filename.$GLOBALS['cfg_df_ext']; } $articleRule = str_replace($arr_rpsource,$arr_rpvalues,$articleRule); if(preg_match("/\{p/", $articleRule)) { $articleRule = str_replace('{pinyin}',GetPinyin($title).'_'.$aid,$articleRule); $articleRule = str_replace('{py}',GetPinyin($title,1).'_'.$aid,$articleRule); } $articleUrl = '/'.preg_replace("/^\//", '', $articleRule); if(preg_match("/index\.html/", $articleUrl) && $cfg_arc_dirname=='Y') { $articleUrl = str_replace('index.html', '', $articleUrl); } return $articleUrl;

2、内容文章分页伪静态

打开 /include/arc.archives.class.php 搜索

$PageList = preg_replace("#.php\?aid=(\d+)#i", '-\\1-1.html', $PageList);

有2处,修改为

$PageList = preg_replace("#view.php\?aid=(\d+)#i", '\\1.html', $PageList);

继续搜索

$PageList = str_replace(".php?aid=", "-", $PageList);

有3处,修改为

$PageList = str_replace("view.php?aid=", "", $PageList);

继续搜索

$PageList = preg_replace("#&pageno=(\d+)#i", '-\\1.html', $PageList);

有3处,修改为

$PageList = preg_replace("#&pageno=(\d+)#i", '_\\1.html', $PageList);

3、TAG标签伪静态链接

打开 /include/taglib/tag.lib.php 搜索

$row['link'] = $cfg_cmsurl."/tags.php?/".urlencode($row['keyword'])."/";

修改为

$row['link'] = $cfg_cmsurl."/tags/".urlencode($row['keyword'])."/";

4、TAG标签分页伪静态链接

打开 /include/arc.taglist.class.php 搜索

$this->PageNo = $GLOBALS['PageNo'];

在它下面加入

if($this->PageNo == 0) { $this->PageNo = 1; }

继续搜索

$prepage="";

在它上面加入

global $cfg_rewrite;

继续搜索

$purl .= "?/".urlencode($this->Tag);

修改为

if($cfg_rewrite == 'Y') { $purl = "/tags/".urlencode($this->Tag); } else { $purl .= "?/".urlencode($this->Tag); }

5、搜索页伪静态链接

打开 /plus/search.php 搜索

$mid = (isset($mid) && is_numeric($mid)) ? $mid : 0;

在它下面加入

if ( $mobile==1 ) { define('DEDEMOB', 'Y'); }

继续搜索

$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;

继续搜索

$purl .= "?".$geturl;

修改为

if($cfg_rewrite != 'Y' && !defined('DEDEMOB')) { $purl .= "?".$geturl; } else { $purl = '/search/'.urlencode($oldkeyword); }

继续搜索

return $plist;

修改为

if($cfg_rewrite == 'Y') { $plist = preg_replace("/PageNo=(\d+)/i",'-\\1.html',$plist); } return $plist;

6、移动版当前位置 {dede:field.position/} 标签动态改成伪静态

打开 /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>"; }

继续搜索

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']; }

7、模板里把搜索框代码改成静态的js提交搜索,参考下面代码,注意标红的地方

电脑端

<script type="text/javascript"> function search() { var q = document.getElementById("q").value; window.location.href = "http://www.verywen.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.verywen.com/search/"+q+".html"; } } </script> <form action="" method="post" onsubmit="return false"> <div class="form"> <h4>搜索</h4> <input name="q" id="q" onkeydown="enterIn(this,event);" type="text" /> <button type="submit" class="search-submit" onclick="search()">搜索</button> </div> </form>

手机端

<script type="text/javascript"> function search() { var q = document.getElementById("q").value; window.location.href = "http://m.verywen.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.verywen.com/search/"+q+".html"; } } </script> <form action="" method="post" onsubmit="return false"> <div class="form"> <h4>搜索</h4> <input name="q" id="q" onkeydown="enterIn(this,event);" type="text" /> <button type="submit" class="search-submit" onclick="search()">搜索</button> </div> </form>

智慧半岛,是一家专注于青岛网站建设青岛网站开发的青岛网络公司,Copyright ©2007-2019 Ebandao.Cn 版权所有 All Rights Reserved.(建议在1366x768以上的浏览器中访问)鲁ICP备08014496号

13153297890