九龙商务代办主页 > 网站建设 > 站长学院 > 织梦dede > dedecms织梦全站伪静态设置+全套伪静态规则

dedecms织梦全站伪静态设置+全套伪静态规则

摘要:请确保你网站所在的主机或者服务器支持伪静态并且已经开启了伪静态功能! 本教程主要设置织梦伪静态页面包括有: 1.列表页 /plus/list-2.html 2.列表页分页 /plus/list-2-26-2.html 3.内容页...

18978939080

立即咨询

编辑: 来源: 发布日期:03-07 浏览量统计中... 反馈错误

  字体:
请确保你网站所在的主机或者服务器支持伪静态并且已经开启了伪静态功能!
 
本教程主要设置织梦伪静态页面包括有:
1.列表页 /plus/list-2.html
2.列表页分页 /plus/list-2-26-2.html
3.内容页 /plus/view-112-1.html
4.内容页分页 /plus/view-112-2.html
5.TAG标签页 /tags/织梦/
6.TAG标签分页 /tags/织梦/2/
7.搜索页 /search/织梦.html
8.搜索页分页 /search/织梦-2.html

网站后台开启伪静态选项


网站后台设置整站为动态

这里可以借助一个小插件来完成,一劳永逸
插件下载懒人包


网站文件修改
1、列表页和内容页伪静态链接
打开 \include\helpers\channelunit.helper.php 找到
  1. global $cfg_typedir_df;
改成
  1. global $cfg_typedir_df, $cfg_rewrite;
继续找到
  1. $reurl = $GLOBALS['cfg_phpurl']."/list.php?tid=".$typeid;
改成
  1. if($cfg_rewrite == 'Y')
  2. {
  3.     $reurl = $GLOBALS["cfg_phpurl"]."/list-".$typeid.'.html';
  4. }
  5. else
  6. {
  7.     //动态
  8.     $reurl = $GLOBALS['cfg_phpurl']."/list.php?tid=".$typeid;
  9. }

2、手机版列表页分页不使用电脑版伪静态
打开 \include\arc.listview.class.php 找到
  1. if($cfg_rewrite == 'Y')
大概在1198行,把这一行改成
  1. if($cfg_rewrite == 'Y' && !defined('DEDEMOB'))

3、TAG标签伪静态链接
打开 \include\taglib\tag.lib.php 找到
  1. $row['link'] = $cfg_cmsurl."/tags.php?/".urlencode($row['keyword'])."/";
改成
  1. $row['link'] = $cfg_cmsurl."/tags/".urlencode($row['keyword'])."/";

4、TAG标签分页伪静态链接
打开 \include\arc.taglist.class.php 找到
  1. $this->PageNo = $GLOBALS['PageNo'];
在它的下面加入
  1. if($this->PageNo == 0)
  2. {
  3.     $this->PageNo = 1;
  4. }
继续找到
  1. $prepage="";
在它的上面加入
  1. global $cfg_rewrite;
继续找到
  1. $purl .= "?/".urlencode($this->Tag);
改成
  1. if($cfg_rewrite == 'Y')
  2. {
  3.     $purl = "/tags/".urlencode($this->Tag);
  4. }
  5. else
  6. {
  7.     $purl .= "?/".urlencode($this->Tag);
  8. }

4、搜索页伪静态链接
打开 \plus\search.php 找到
  1. $t1 = ExecTime();
在它的下面加入
  1. $keyword = preg_replace("/-(\d+)/i",'',$keyword);
  2. $oldkeyword = preg_replace("/-(\d+)/i",'',$oldkeyword);
打开 \include\arc.searchview.class.php 找到
  1. global $oldkeyword;
改成
  1. global $oldkeyword, $cfg_rewrite;
继续找到
  1. $purl .= "?".$geturl;
改成
  1. if($cfg_rewrite != 'Y' && !defined('DEDEMOB'))
  2. {
  3.     $purl .= "?".$geturl;
  4. }
  5. else
  6. {
  7.     $purl = '/search/'.urlencode($oldkeyword);
  8. }
继续找到
  1. return $plist;
在它的上面加入
  1. if($cfg_rewrite == 'Y' && !defined('DEDEMOB'))
  2. {
  3.     $plist = preg_replace("/PageNo=(\d+)/i",'-\\1.html',$plist);
  4. }

最后还需要在你模板里搜索框代码改成静态的js提交搜索,参考下面代码,注意红框的地方
  1. <script type="text/javascript">
  2. function search()
  3. {
  4.     var q = document.getElementById("q").value;
  5.     window.location.href = "http://www.2l3.net/search/"+q+".html";
  6. }
  7. function enterIn(obj,evt)
  8. {
  9.     var evt = evt ? evt : (window.event ? window.event : null);
  10.     if (evt.keyCode == 13)
  11.     {
  12.         var q = obj.value;
  13.         window.location.href = "http://www.2l3.net/search/"+q+".html";
  14.     }
  15. }
  16. </script>
  17. <form action="" method="post" onsubmit="return false">
  18.     <div class="form">
  19.         <h4>搜索</h4>
  20.         <input name="q" id="q" onkeydown="enterIn(this,event);" type="text" />
  21.         <button type="submit" class="search-submit" onclick="search()">搜索</button>
  22.     </div>
  23. </form>

伪静态规则
懒人包已经打包了iis6、iis7、8、apache、nginx的规则文件
下面再写一下各规则

iis6伪静态规则 httpd.ini
  1. #列表页和列表分页
  2. RewriteRule ^(.*)/plus/list-([0-9]+)\.html $1/plus/list\.php\?tid=$2
  3. RewriteRule ^(.*)/plus/list-([0-9]+)-([0-9]+)-([0-9]+)\.html $1/plus/list\.php\?tid=$2&TotalResult=$3&PageNo=$4
  4. #内容页和内容分页
  5. RewriteRule ^(.*)/plus/view-([0-9]+)-([0-9]+)\.html $1/plus/view\.php\?arcID=$2&pageno=$3
  6. #TAG标签伪静态规则
  7. RewriteRule ^(.*)/tags\.html $1/tags\.php [I]
  8. RewriteRule ^(.*)/tags/(.*)(?:(\?.*))* $1/tags\.php\?\/$2 [I]
  9. RewriteRule ^(.*)/tags/(.*)\/(?:(\?.*))* $1/tags\.php\?\/$2\/ [I]
  10. RewriteRule ^(.*)/tags/(.*)\/([0-9])(?:(\?.*))* $1/tags\.php\?\/$2\/$3 [I]
  11. RewriteRule ^(.*)/tags/(.*)\/([0-9])\/(?:(\?.*))* $1/tags\.php\?\/$2\/$3\/ [I]
  12. #搜索页
  13. RewriteRule ^(.*)/search/(.*)-([0-9]+)\.html  $1/plus/search.php?q=$2&PageNo=$3&pagesize=2&searchtype=title
  14. RewriteRule ^(.*)/search/(.*)\.html  $1/plus/search.php?q=$2&pagesize=2&searchtype=title

iis7、8伪静态规则 web.config
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <configuration>
  3.     <system.webServer>
  4.         <rewrite>
  5.             <rules>
  6.                 <rule name="首页">
  7.                     <match url="^index.html$" ignoreCase="false" />
  8.                     <action type="Rewrite" url="index.php" appendQueryString="false" />
  9.                 </rule>
  10.                 <rule name="列表">
  11.                     <match url="^plus/list-([0-9]+).html$" ignoreCase="false" />
  12.                     <action type="Rewrite" url="/plus/list.php?tid={R:1}" appendQueryString="false" />
  13.                 </rule>
  14.                 <rule name="列表分页">
  15.                     <match url="^plus/list-([0-9]+)-([0-9]+)-([0-9]+).html$" ignoreCase="false" />
  16.                     <action type="Rewrite" url="/plus/list.php?tid={R:1}&amp;totalresult={R:2}&amp;PageNo={R:3}" appendQueryString="false" />
  17.                 </rule>
  18.                 <rule name="文章分页">
  19.                     <match url="^plus/view-([0-9]+)-([0-9]+).html$" ignoreCase="false" />
  20.                     <action type="Rewrite" url="/plus/view.php?aid={R:1}&amp;pageno={R:2}" appendQueryString="false" />
  21.                 </rule>
  22. <rule name="tag首页">
  23. <match url="^tags.html$" ignoreCase="false" />
  24. <action type="Rewrite" url="tags.php" appendQueryString="false" />
  25. </rule>
  26. <rule name="tag列表">
  27. <match url="^tags/(.*)(?:(\?.*))*$" ignoreCase="false" />
  28. <action type="Rewrite" url="/tags.php?/{R:1}" appendQueryString="false" />
  29. </rule>
  30. <rule name="tag列表最后有左斜杠">
  31. <match url="^tags/(.*)/(?:(\?.*))*$" ignoreCase="false" />
  32. <action type="Rewrite" url="/tags.php?/{R:1}/" appendQueryString="false" />
  33. </rule>
  34. <rule name="tag列表分页">
  35. <match url="^tags/(.*)/([0-9])(?:(\?.*))*$" ignoreCase="false" />
  36. <action type="Rewrite" url="/tags.php?/{R:1}/{R:2}" appendQueryString="false" />
  37. </rule>
  38. <rule name="tag列表分页最后有左斜杠">
  39. <match url="^tags/(.*)/([0-9])/(?:(\?.*))*$" ignoreCase="false" />
  40. <action type="Rewrite" url="/tags.php?/{R:1}/{R:2}/" appendQueryString="false" />
  41. </rule>
  42. <rule name="搜索页分页">
  43.                     <match url="^search/(.*)-([0-9]+).html$" ignoreCase="false" />
  44.                     <action type="Rewrite" url="/plus/search.php?q={R:1}&amp;PageNo={R:2}&amp;pagesize=2&amp;searchtype=title" appendQueryString="false" />
  45.                 </rule>
  46. <rule name="搜索页">
  47.                     <match url="^search/(.*).html$" ignoreCase="false" />
  48.                     <action type="Rewrite" url="/plus/search.php?q={R:1}&amp;pagesize=2&amp;searchtype=title" appendQueryString="false" />
  49.                 </rule>
  50.             </rules>
  51.         </rewrite>
  52.     </system.webServer>
  53. </configuration>

apache伪静态规则 .htaccess
  1. #列表页和列表分页
  2. RewriteRule ^plus/list-([0-9]+)\.html$ plus/list.php?tid=$1
  3. RewriteRule ^plus/list-([0-9]+)-([0-9]+)-([0-9]+)\.html$ plus/list.php?tid=$1&TotalResult=$2&PageNo=$3      
  4. #内容页和内容分页
  5. RewriteRule ^plus/view-([0-9]+)-([0-9]+)\.html$ plus/view.php?arcID=$1&pageno=$2
  6. #TAG标签
  7. RewriteRule ^tags\.html$ tags\.php
  8. RewriteRule ^tags/(.*)(?:(\?.*))* tags\.php\?\/$1
  9. RewriteRule ^tags/(.*)\/(?:(\?.*))*  tags\.php\?\/$1\/
  10. RewriteRule ^tags/(.*)\/([0-9])(?:(\?.*))* tags\.php\?\/$1\/$2
  11. RewriteRule ^tags/(.*)\/([0-9])\/(?:(\?.*))*  tags\.php\?\/$1\/$2\/
  12. #搜索页
  13. RewriteRule ^search/(.*)-([0-9]+)\.html$  plus/search.php?q=$1&PageNo=$2&pagesize=2&searchtype=title
  14. RewriteRule ^search/(.*)\.html$  plus/search.php?q=$1&pagesize=2&searchtype=title

nginx伪静态规则
  1. rewrite ^/plus/list-([0-9]+)\.html$ /plus/list.php?tid=$1;
  2. rewrite ^/plus/list-([0-9]+)-([0-9]+)-([0-9]+)\.html$ /plus/list.php?tid=$1&totalresult=$2&PageNo=$3;
  3. rewrite ^/plus/view-([0-9]+)-1\.html$ /plus/view.php?arcID=$1;
  4. rewrite ^/plus/view-([0-9]+)-([0-9]+)\.html$ /plus/view.php?aid=$1&pageno=$2;
  5. rewrite ^/tags\.html$ /tags.php;
  6. rewrite ^/tags/(.*)(?:(\?.*))* /tags.php?/$1;
  7. rewrite ^/tags/(.*)/(?:(\?.*))*  /tags.php?/$1/;
  8. rewrite ^/tags/(.*)/([0-9])(?:(\?.*))* /tags.php?/$1/$2;
  9. rewrite ^/tags/(.*)/([0-9])/(?:(\?.*))*  /tags.php?/$1/$2/;
  10. rewrite ^/search/(.*)-([0-9]+)\.html$  /plus/search.php?q=$1&PageNo=$2&pagesize=2&searchtype=title;
  11. rewrite ^/search/(.*)\.html$  /plus/search.php?q=$1&pagesize=2&searchtype=title;
提取密码:jg2y

    更多相关阅读

【九龙商务代办】微信号

官方微信公众号

24小时电话18978939080

民族大道49号民族宫B座2306号(新梦之岛楼上)

工商注册13807817411
其他业务13878807671
 
【九龙商务代办】QQ
QQ在线咨询
客服咨询
【九龙商务代办】QQ
【九龙商务代办】QQ
【九龙商务代办】QQ
【九龙商务代办】QQ
咨询热线
18978939080
13807817411
13878807671
0771-5537667

反馈
【九龙商务代办】微信号扫描二维码关注我为好友
浏览: