织梦DedeCms v5.7如何设置全站伪静态(2)

3、开启DedeCms伪静态支持并不能完全在后台配置,有很多地方还是需要手动修改的。下面讲解DedeCms全站伪静态的实现方法,适用于V5.3以上版本。这次的DedeCms伪静态测试环境是Windows IIS6,对于Linux或其它服务器的伪静态实现原理都是一样的,只要搞清楚思路就行。

1)DedeCms首页伪静态:

把站点根目录下index.html删除,以后不更新主页HTML就可以了,当然你也可以选择不使用动态首页。

2)DedeCms频道|列表页|文章页伪静态:

主要通过修改GetFileName()、GetTypeUrl()这两个函数实现。DedeCms V5.3、DedeCms V5.5和DedeCms V5.6版本,打开/include/channelunit.func.php进行修改。注意:DedeCms V5.7,此文件路径更改了,你打开/include/helpers/channelunit.helper.php即可。 

        A.将GetTypeUrl()中的如下代码:
  //动态
  $reurl = $GLOBALS['cfg_phpurl']."/list.php?tid=".$typeid;
  替换为
  //动态
  $reurl = "/category/list-".$typeid.".html";
  这步必须修改,即让你的频道或是列表页URL变更为/category/list-1.html形式。

     B.将GetFileName()中的如下代码:
  //动态文章
  if($cfg_rewrite == 'Y')
  {
  return $GLOBALS["cfg_plus_dir"]."/view-".$aid.'-1.html';
  }
  替换为
  //动态文章
  if($cfg_rewrite == 'Y')
  {
  return "/archives/view-".$aid.'-1.html';
  }
  将文章页默认的/plus/view-1-1.html链接格式改为/archives/view-1-1.html,随个人喜好,不改也行。   

3)DedeCms列表分页伪静态:

  打开/include/arc.listview.class.php,找到获取动态的分页列表GetPageListDM()函数末尾处:
  $plist = str_replace('.php?tid=', '-', $plist);
  替换为
  $plist = str_replace('plus', 'category', $plist);//将默认的plus替换成category
  $plist = str_replace('.php?tid=', '-', $plist);
  将列表分页默认链接格式/plus/list-1-2-1.html修改为/category/list-1-2-1.html,这步也可以不作更改。

4)DedeCms文章分页伪静态:

  打开/include/arc.archives.class.php,找到获取动态的分页列表GetPagebreakDM()函数末尾片:
  $PageList = str_replace(".php?aid=","-",$PageList);
  替换为
  $plist = str_replace('plus', 'archives', $plist);//将默认的plus替换成archives
  $PageList = str_replace(".php?aid=","-",$PageList);
  这步不作修改也可以,只是个人喜好问题。

5)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'])."/";
  到这里,TAG标签URL中的“.php?”号就去掉了。

6)DedeCms搜索伪静态:

  DedeCms搜索URL静态化比较麻烦,附带参数多不说,参数也可能变化,像搜索结果分页的URL就特麻烦,伪静态规则匹配复杂。将搜索URL中“search.php?…”直接替换为“search.html?…”,至于“?”号之后的参数以任意字符进行匹配。
  依次打开include文件夹下的channelunit.func.php、arc.searchview.class.php、arc.taglist.class.php以及/include/taglib/hotwords.lib.php,查找“search.php?”替换为“search.html?”即可。

7)DedeCms问答伪静态:

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/b3ff7ce02d3bb831c62af3200ae22ba6.html