时间:2021-07-21人气:-
请确保你网站所在的主机或者服务器支持伪静态并且已经开启了伪静态功能!
本教程主要设置织梦伪静态页面包括有:
列表页/plus/list-2.html
列表页分页/plus/list-2-26-2.html
内容页/plus/view-112-1.html
内容页分页/plus/view-112-2.html
TAG标签页/tags/织梦/
TAG标签分页/tags/织梦/2/
搜索页/search/织梦.html
搜索页分页/search/织梦-2.html
网站后台开启伪静态选项
后台-系统参数-核心设置-是否使用伪静态:"是"
(此图片来源于网络,如有侵权,请联系删除! )
网站后台设置整站为动态
这里可以借助我写的一个小插件来完成,一劳永逸
插件介绍及下载地址http://www.dede58.com/a/dedejq/8624.html
1、列表页和内容页伪静态链接
打开includehelperschannelunit.helper.php找到
global $cfg_typedir_df;
改成
global $cfg_typedir_df, $cfg_rewrite;
继续找到
$reurl = $GLOBALS['cfg_phpurl']."/list.php?tid=".$typeid;
改成
123456789if($cfg_rewrite=='Y'){$reurl=$GLOBALS["cfg_phpurl"]."/list-".$typeid.'.html';}else{//动态$reurl=$GLOBALS['cfg_phpurl']."/list.php?tid=".$typeid;}2、手机版列表页分页不使用电脑版伪静态
打开includerc.listview.class.php找到
if($cfg_rewrite == 'Y')
大概在1198行,把这一行改成
if($cfg_rewrite == 'Y' && !defined('DEDEMOB'))
3、TAG标签伪静态链接
打开include aglib ag.lib.php找到
$row['link'] = $cfg_cmsurl."/tags.php?/".urlencode($row['keyword'])."/";
改成
$row['link'] = $cfg_cmsurl."/tags/".urlencode($row['keyword'])."/";
4、TAG标签分页伪静态链接
打开includerc.taglist.class.php找到
$this->PageNo = $GLOBALS['PageNo'];
在它的下面加入
if($this->PageNo == 0)
{
$this->PageNo = 1;
}
继续找到
$prepage="";
在它的上面加入
global $cfg_rewrite;
继续找到
$purl .= "?/".urlencode($this->Tag);
改成
12345678if($cfg_rewrite=='Y'){$purl="/tags/".urlencode($this->Tag);}else{$purl.="?/".urlencode($this->Tag);}4、搜索页伪静态链接
打开plussearch.php找到
$t1 = ExecTime();
在它的下面加入
$keyword = preg_replace("/-(d+)/i",'',$keyword);
$oldkeyword = preg_replace("/-(d+)/i",'',$oldkeyword);
打开includerc.searchview.class.php找到
global $oldkeyword;
改成
global $oldkeyword, $cfg_rewrite;
继续找到
$purl .= "?".$geturl;
改成
if($cfg_rewrite != 'Y' && !defined('DEDEMOB'))
{
$purl .= "?".$geturl;
}
else
{
$purl = '/search/'.urlencode($oldkeyword);
}
继续找到
return $plist;
在它的上面加入
if($cfg_rewrite == 'Y' && !defined('DEDEMOB'))
{
$plist = preg_replace("/PageNo=(d+)/i",'-1.html',$plist);
}
最后还需要在你模板里搜索框代码改成静态的js提交搜索,参考下面代码,注意标红的地方
<script type="text/javascript">
functionsearch()
{
var q = document.getElementById("q").value;
window.location.href = "http://www.dede58.com/search/"+q+".html";
}
function enterIn(obj,evt)
{
var evt = evt ? evt : (window.event ? window.event : null);
if (evt.keyCode == 13)
{
var q = obj.value;
window.location.href = "http://www.dede58.com/search/"+q+".html";
}
}
</script>
<formaction=""method="post"onsubmit="return false">
<div>
<h4>搜索</h4>
<inputname="q" id="q" onkeydown="enterIn(this,event);"type="text" />
<button type="submit"onclick="search()">搜索</button>
</div>
</form>
伪静态规则文件打包下载
云盘下载http://pan.baidu.com/s/1bpNIEN9 密码: vf18
iis7、8伪静态规则web.config
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253<?xmlversion="1.0"encoding="UTF-8"?><configuration><system.webServer><rewrite><rules><rulename="首页"><matchurl="^index.html$"ignoreCase="false"/><actiontype="Rewrite"url="index.php"appendQueryString="false"/></rule><rulename="列表"><matchurl="^plus/list-([0-9]+).html$"ignoreCase="false"/><actiontype="Rewrite"url="/plus/list.php?tid={R:1}"appendQueryString="false"/></rule><rulename="列表分页"><matchurl="^plus/list-([0-9]+)-([0-9]+)-([0-9]+).html$"ignoreCase="false"/><actiontype="Rewrite"url="/plus/list.php?tid={R:1}&totalresult={R:2}&PageNo={R:3}"appendQueryString="false"/></rule><rulename="文章分页"><matchurl="^plus/view-([0-9]+)-([0-9]+).html$"ignoreCase="false"/><actiontype="Rewrite"url="/plus/view.php?aid={R:1}&pageno={R:2}"appendQueryString="false"/></rule><rulename="tag首页"><matchurl="^tags.html$"ignoreCase="false"/><actiontype="Rewrite"url="tags.php"appendQueryString="false"/></rule><rulename="tag列表"><matchurl="^tags/(.*)(?:(?.*))*$"ignoreCase="false"/><actiontype="Rewrite"url="/tags.php?/{R:1}"appendQueryString="false"/></rule><rulename="tag列表最后有左斜杠"><matchurl="^tags/(.*)/(?:(?.*))*$"ignoreCase="false"/><actiontype="Rewrite"url="/tags.php?/{R:1}/"appendQueryString="false"/></rule><rulename="tag列表分页"><matchurl="^tags/(.*)/([0-9])(?:(?.*))*$"ignoreCase="false"/><actiontype="Rewrite"url="/tags.php?/{R:1}/{R:2}"appendQueryString="false"/></rule><rulename="tag列表分页最后有左斜杠"><matchurl="^tags/(.*)/([0-9])/(?:(?.*))*$"ignoreCase="false"/><actiontype="Rewrite"url="/tags.php?/{R:1}/{R:2}/"appendQueryString="false"/></rule><rulename="搜索页分页"><matchurl="^search/(.*)-([0-9]+).html$"ignoreCase="false"/><actiontype="Rewrite"url="/plus/search.php?q={R:1}&PageNo={R:2}&pagesize=2&searchtype=title"appendQueryString="false"/></rule><rulename="搜索页"><matchurl="^search/(.*).html$"ignoreCase="false"/><actiontype="Rewrite"url="/plus/search.php?q={R:1}&pagesize=2&searchtype=title"appendQueryString="false"/></rule></rules></rewrite></system.webServer></configuration>apache伪静态规则.htaccess
1234567891011121314151617181920212223242526#列表页和列表分页RewriteRule^plus/list-([0-9]+).html$plus/list.php?tid=$1RewriteRule^plus/list-([0-9]+)-([0-9]+)-([0-9]+).html$plus/list.php?tid=$1&TotalResult=$2&PageNo=$3#内容页和内容分页RewriteRule^plus/view-([0-9]+)-([0-9]+).html$plus/view.php?arcID=$1&pageno=$2#TAG标签RewriteRule^tags.html$tags.phpRewriteRule^tags/(.*)(?:(?.*))*tags.php?/$1RewriteRule^tags/(.*)/(?:(?.*))*tags.php?/$1/RewriteRule^tags/(.*)/([0-9])(?:(?.*))*tags.php?/$1/$2RewriteRule^tags/(.*)/([0-9])/(?:(?.*))*tags.php?/$1/$2/#搜索页RewriteRule^search/(.*)-([0-9]+).html$plus/search.php?q=$1&PageNo=$2&pagesize=2&searchtype=titleRewriteRule^search/(.*).html$plus/search.php?q=$1&pagesize=2&searchtype=titlenginx伪静态规则rewrite^/plus/list-([0-9]+).html$/plus/list.php?tid=$1;rewrite^/plus/list-([0-9]+)-([0-9]+)-([0-9]+).html$/plus/list.php?tid=$1&totalresult=$2&PageNo=$3;rewrite^/plus/view-([0-9]+)-1.html$/plus/view.php?arcID=$1;rewrite^/plus/view-([0-9]+)-([0-9]+).html$/plus/view.php?aid=$1&pageno=$2;rewrite^/tags.html$/tags.php;rewrite^/tags/(.*)(?:(?.*))*/tags.php?/$1;rewrite^/tags/(.*)/(?:(?.*))*/tags.php?/$1/;rewrite^/tags/(.*)/([0-9])(?:(?.*))*/tags.php?/$1/$2;rewrite^/tags/(.*)/([0-9])/(?:(?.*))*/tags.php?/$1/$2/;rewrite^/search/(.*)-([0-9]+).html$/plus/search.php?q=$1&PageNo=$2&pagesize=2&searchtype=title;rewrite^/search/(.*).html$/plus/search.php?q=$1&pagesize=2&searchtype=title;