栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > PHP > php开源框架 > dedecms

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

dedecms 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

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

请确保你网站所在的主机或者服务器支持伪静态并且已经开启了伪静态功能!   本教程主要设置织梦伪静态页面包括有: 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、列表页和内容页伪静态链接 打开 includehelperschannelunit.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、手机版列表页分页不使用电脑版伪静态
打开 includearc.listview.class.php 找到
  1. if($cfg_rewrite == 'Y')
大概在1198行,把这一行改成
  1. if($cfg_rewrite == 'Y' && !defined('DEDEMOB'))

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

4、TAG标签分页伪静态链接
打开 includearc.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、搜索页伪静态链接
打开 plussearch.php 找到
  1. $t1 = ExecTime();
在它的下面加入
  1. $keyword = preg_replace("/-(d+)/i",'',$keyword);
  2. $oldkeyword = preg_replace("/-(d+)/i",'',$oldkeyword);
打开 includearc.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提交搜索,参考下面代码,注意红框的地方

伪静态规则
懒人包已经打包了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.    
  2.        
  3.            
  4.                
  5.                    
  6.                    
  7.                
  8.                
  9.                    
  10.                    
  11.                
  12.                
  13.                    
  14.                    
  15.                
  16.                
  17.                    
  18.                    
  19.                
  20.                    
  21.                    
  22.                
  23.                    
  24.                    
  25.                
  26.            
  27.        
  28.    

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
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/6109.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号