星联网络专注帝国CMS二次功能插件开发-精品网站模板站长代码素材

  • 最近更新
  • 模板:33
  • 记录:12640|
  • 插件:52|
  • 工具:4|
  • 代码:8|
  • 评论:0

织梦Dedecms设置伪静态详细方法

前言

dedecms默认是不支持伪静态,如果要设置伪静态我们需要懂一点程序基础知识了,下面我来给大家介绍在apache下实现Dedecms设置伪静态方法,有需要的朋友可参考一下

首先在dede后台开启伪静态(开启的方法在系统参数-核心设置)
第一步. 首先栏目和文章最好设置成动态浏览. 这样才不会生成静态html文件.
第二步. 设置重写规则. 在系统目录下加一个 .htaccess文件. 内容为:
代码如下:

RewriteEngine On
RewriteRule ^plus/list-([0-9]+).html$ /plus/list.php?tid=$1
RewriteRule ^plus/list-([0-9]+)-([0-9]+)-([0-9]+).html$ /plus/list.php?tid=$1&totalresult=$2&PageNo=$3
RewriteRule ^plus/view-([0-9]+)-1.html$ /plus/view.php?arcID=$1
RewriteRule ^plus/view-([0-9]+)-([0-9]+).html$ /plus/view.php?aid=$1&pageno=$2


iis文件写法
代码如下:

#首页伪静态规则,如果不使用动态首页,请勿必删除这一行,否则打开首页会出现死循环
RewriteRule ^(.*)/index.html $1/index.php [I]
#列表页伪静态规则
RewriteRule ^(.*)/category/list-([0-9]+).html $1/plus/list.php?tid=$2 [I]
RewriteRule ^(.*)/category/list-([0-9]+)-([0-9]+)-([0-9]+).html $1/plus/list.php?tid=$2&TotalResult=$3&PageNo=$4 [I]
#文章页伪静态规则
RewriteRule ^(.*)/archives/view-([0-9]+)-([0-9]+).html $1/plus/view.php?arcID=$2&pageno=$3 [I]
#搜索伪静态规则
RewriteRule ^(.*)/search.html(?:(?.*))* $1/search.php?$2 [I]
#TAG标签伪静态规则
RewriteRule ^(.*)/tags.html $1/tags.php [I]
RewriteRule ^(.*)/tags/(.*)(?:(?.*))* $1/tags.php?/$2 [I]
RewriteRule ^(.*)/tags/(.*)/(?:(?.*))* $1/tags.php?/$2/ [I]
RewriteRule ^(.*)/tags/(.*)/([0-9])(?:(?.*))* $1/tags.php?/$2/$3 [I]
RewriteRule ^(.*)/tags/(.*)/([0-9])/(?:(?.*))* $1/tags.php?/$2/$3/ [I]


如果你的系统支持url重写,到这里就可以用伪静态访问了.
第三步.更改重写的URL.
如果用默认的设置, 访问的URL是:
代码如下:
http://www.XXXX.com/plus/view-131-1.html
这样的形色, 我们是可以更改这种样式的.
找到文件/include/helpers/channelunit.helper.php打开.
可以看到有这样的语句
代码如下:
return $GLOBALS["cfg_plus_dir"]."/view-".$aid.'-1.html';
这就是文章的url形色.
$reurl = $GLOBALS['cfg_phpurl']."/list.php?tid=".$typeid;
这是列表的重写url.
可以使url更短一点,完成可以写成:
代码如下:
return "/view-".$aid.'-1.html';

$reurl = "/list-".$typeid.".html";
这时重写规则也要更新.
代码如下:

RewriteEngine On
RewriteRule ^list-([0-9]+).html$ /plus/list.php?tid=$1
RewriteRule ^list-([0-9]+)-([0-9]+)-([0-9]+).html$ /plus/list.php?tid=$1&totalresult=$2&PageNo=$3
RewriteRule ^view-([0-9]+)-1.html$ /plus/view.php?arcID=$1
RewriteRule ^view-([0-9]+)-([0-9]+).html$ /plus/view.php?aid=$1&pageno=$2


更进一步,还可以把view换成自己的任何词语,这也要把include/arc.archives.class.php文件中的view也一样替换。
发布选项: 生成HTML 仅动态浏览 发文章的时候选一下也不多事。为了以后升级 尽量减少修改文件。
以下这没有试,大家按需要测试吧~~
修改数据库
将所有文档设置为“仅动态”,可以进入数据库管理中,执行下面命令:
代码如下:
update dede_archives set ismake=-1
并将ismake的默认值设置为 -1即动态。
将所有栏目设置为“使用动态页”,可以进入数据库管理中,执行下面命令:
代码如下:
update dede_arctype set isdefault=-1
DedeCmsTAG标签伪静态
DedeCms默认的TAG标签URL,形如/tags.php?/dedecms5.7/,非常之难看。打开/include/taglib/tag.lib.php,找到lib_tag()函数下的:
代码如下:

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

替换为

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

修改分页代码
我们需要修改include/arc.taglist.class.php,将分页函数替换为:
代码如下:

/** * 获取动态的分页列表
*
* @access public
* @param int $list_len 列表宽度
* @param string $listitem 列表样式
* @return string
*/
function GetPageListDM($list_len,$listitem="info,index,end,pre,next,pageno")
{
$prepage="";
$nextpage="";
$prepagenum = $this->PageNo - 1;
$nextpagenum = $this->PageNo + 1;
if($list_len == "" || preg_match("/[^0-9]/", $list_len))
{
$list_len = 3;
}
$totalpage = $this->TotalPage;
if($totalpage <= 1 && $this->TotalResult > 0)
{
return "<span class="pageinfo">共1页/".$this->TotalResult."条</span>";
}
if($this->TotalResult == 0)
{
return "<span class="pageinfo">共0页/".$this->TotalResult."条</span>";
}
$maininfo = "<span class="pageinfo">共{$totalpage}页/".$this->TotalResult."条</span>rn";
$purl = $this->GetCurUrl();
$basename = basename($purl);
$tmpname = explode('.', $basename);
$purl = str_replace($basename, '', $purl).urlencode($this->Tag);
//var_dump($purl);exit;
//$purl .= "?/".urlencode($this->Tag);
//获得上一页和下一页的链接
if($this->PageNo != 1)
{
$prepage.="<li><a href='".$purl."-$prepagenum'.html>上一页</a></li>rn";
$indexpage="<li><a href='".$purl."-1.html'>首页</a></li>rn";
}
else
{
$indexpage="<li><a>首页</a></li>rn";
}
if($this->PageNo!=$totalpage && $totalpage>1)
{
$nextpage.="<li><a href='".$purl."-$nextpagenum.html'>下一页</a></li>rn";
$endpage="<li><a href='".$purl."-$totalpage.html'>末页</a></li>rn";
}
else
{
$endpage="<li><a>末页</a></li>rn";
}
//获得数字链接
$listdd="";
$total_list = $list_len * 2 + 1;
if($this->PageNo >= $total_list)
{
$j = $this->PageNo - $list_len;
$total_list = $this->PageNo + $list_len;
if($total_list > $totalpage)
{
$total_list = $totalpage;
}
}
else
{
$j=1;
if($total_list > $totalpage)
{
$total_list = $totalpage;
}
}
for($j; $j<=$total_list; $j++)
{
if($j == $this->PageNo)
{
$listdd.= "<li class="thisclass"><a>$j</a></li>rn";
}
else
{
$listdd.="<li><a href='".$purl."-$j.html'>".$j."</a></li>rn";
}
}
$plist = '';
if(preg_match('/info/i', $listitem))
{
$plist .= $maininfo.' ';
}
if(preg_match('/index/i', $listitem))
{
$plist .= $indexpage.' ';
}
if(preg_match('/pre/i', $listitem))
{
$plist .= $prepage.' ';
}
if(preg_match('/pageno/i', $listitem))
{
$plist .= $listdd.' ';
}
if(preg_match('/next/i', $listitem))
{
$plist .= $nextpage.' ';
}
if(preg_match('/end/i', $listitem))
{
$plist .= $endpage.' ';
}
return $plist;
}

本网刊登的文章均仅代表作者个人观点,并不代表本网立场。文中的论述和观点,敬请读者注意判断。

本文地址:http://www.xlkjgs.com/notes/web/14314.html

以上内容由本站整理呈现,请务必在转载分享时注明本文地址!如对内容有疑问,请联系我们,谢谢!

星联网络

星联网络是中国最具实战的互联网创业者的知识服务商,这里有互联网行业动态,网络推广,SEO优化,SEM优化,ESC配置,行业经验分型,互联网项目,微信营销、淘宝客赚钱、新媒体营销、京东运营、跨境电商等众多互联网营销知识分享

站长运营站长必备网站运营之道才能长久发展