织梦DedeCMS5.7全站伪静态实现方法(2)

  DedeCms搜索URL静态化比较麻烦,附带参数多不说,参数也可能变化,像搜索结果分页的URL就特麻烦,伪静态规则匹配复杂。随州SEO就偷下懒,将搜索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问答伪静态

  问答模块的伪静态实现比较简单,只要后台开启伪静态支持即可,至于个别页面,如ask目录下的browser.php、question.php以及 include目录下的common.inc.php、functions.inc.php都需要简单修改才可以匹配伪静态规则。

  注意一点,DedeCmsV5.7问答模块整体升级了,之前的规则已经不适用了,以后会专门写个教程供大家参考的。

  8.DedeCms伪静态规则

  依照上面的步骤修改完毕,接下来配置好你的伪静态规则,DedeCms全站伪静态就完美实现了。

  1)IIS伪静态

  打开httpd.ini文件,加入如下规则:

  #首页伪静态规则,如果不使用动态首页,请勿必删除这一行,否则打开首页会出现死循环

  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]

  #问答伪静态规则,适用于DedeCmsV5.3-5.6版本,需要修改几处程序

  RewriteRule ^(.*)/post.html $1/post.php [I]

  RewriteRule ^(.*)/type.html $1/type.php [I]

  RewriteRule ^(.*)/question-([0-9]+).html $1/question.php?id=$2 [I]

  RewriteRule ^(.*)/browser-1-([0-9]+).html $1/browser.php?tid=$2 [I]

  RewriteRule ^(.*)/browser-2-([0-9]+).html $1/browser.php?tid2=$2 [I]

  RewriteRule ^(.*)/browser-1-([0-9]+)-([0-9]+).html $1/browser.php?tid=$2&page=$3 [I]

  RewriteRule ^(.*)/browser-2-([0-9]+)-([0-9]+).html $1/browser.php?tid2=$2&page=$3 [I]

  RewriteRule ^(.*)/browser-([0-9]+).html $1/browser.php?lm=$2 [I]

  RewriteRule ^(.*)/browser-1-([0-9]+)-([0-9]+).html $1/browser.php?tid=$2&lm=$3 [I]

  RewriteRule ^(.*)/browser-2-([0-9]+)-([0-9]+).html $1/browser.php?tid2=$2&lm=$3 [I]

  2)Apache伪静态

  打开.htaccess文件,加入如下规则:

  #提供部分规则作参考

  RewriteRule ^category/list-([0-9]+).html$ /plus/list.php?tid=$1

  RewriteRule ^category/list-([0-9]+)-([0-9]+)-([0-9]+).html$ /plus/list.php?tid=$1&totalresult=$2&PageNo=$3

  RewriteRule ^archives/view-([0-9]+)-([0-9]+).html$ /plus/view.php?arcID=$1&pageno=$2

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

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