专注网站优化推广技术
网站优化排名

织梦DEDECMS全站目录化伪静态设置教程(电脑端+手机端)

织梦全站伪静态后台设置教程

织梦全站伪静态后台设置:

一、后台-系统参数-核心设置-开启伪静态

启用全站伪静态

核心设置里面,启用绝对网址关闭

启用绝对地址

二、安装全站动静态插件,(按照您对应的织梦网站编码安装,否则会乱码出错)下载的压缩包里有。设置全站为动态。

三、后台添加两个新变量:

变量名称:cfg_mobile
变量类型:文本
参数说明:手机版网址
变量值:http://m.tengtubz.com
所属组:站点设置
手机版根网址设置
变量名称:cfg_rewritem
变量类型:布尔(Y/N)
参数说明:手机版伪静态
变量值:Y
所属组:站点设置

手机版伪静态变量设置

手机伪静态

织梦全站伪静态模板设置教程

四、模板里把搜索框代码改成静态的js提交搜索,参考下面代码,注意标红的地方

电脑端

<script type="text/javascript">
function search()
{
    var q = document.getElementById("q").value;
    window.location.href = "https://www.360gzseo.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 = "https://www.360gzseo.com/search/"+q+".html";
    }
}
</script>
<form action="" method="post" onsubmit="return false">
    <div class="form">
        <h4>搜索</h4>
        <input name="q" id="q" onkeydown="enterIn(this,event);" type="text" />
        <button type="submit" class="search-submit" onclick="search()">搜索</button>
    </div>
</form>

手机端

<script type="text/javascript">
function search()
{
    var q = document.getElementById("q").value;
    window.location.href = "https://www.360gzseo.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 = "https://www.360gzseo.com/search/"+q+".html";
    }
}
</script>
<form action="" method="post" onsubmit="return false">
    <div class="form">
        <h4>搜索</h4>
        <input name="q" id="q" onkeydown="enterIn(this,event);" type="text" />
        <button type="submit" class="search-submit" onclick="search()">搜索</button>
    </div>
</form>

 

五、分别把电脑版及手机版的伪静态规则设置好,根据你的运行环境选择相应的规则。

六、电脑端模板添加跳转代码:

主页

<meta http-equiv="mobile-agent" content="format=xhtml;url={dede:global.cfg_mobile/}">
<script type="text/javascript">if(window.location.toString().indexOf('pref=padindex') != -1){}else{if(/AppleWebKit.*Mobile/i.test(navigator.userAgent) || (/MIDP|SymbianOS|NOKIA|SAMSUNG|LG|NEC|TCL|Alcatel|BIRD|DBTEL|Dopod|PHILIPS|HAIER|LENOVO|MOT-|Nokia|SonyEricsson|SIE-|Amoi|ZTE/.test(navigator.userAgent))){if(window.location.href.indexOf("?mobile")<0){try{if(/Android|Windows Phone|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)){window.location.href="{dede:global.cfg_mobile/}";}else if(/iPad/i.test(navigator.userAgent)){}else{}}catch(e){}}}}</script>

列表页

<meta http-equiv="mobile-agent" content="format=xhtml;url={dede:global.cfg_mobile/}{dede:type}[field:typeurl/]{/dede:type}">
<script type="text/javascript">if(window.location.toString().indexOf('pref=padindex') != -1){}else{if(/AppleWebKit.*Mobile/i.test(navigator.userAgent) || (/MIDP|SymbianOS|NOKIA|SAMSUNG|LG|NEC|TCL|Alcatel|BIRD|DBTEL|Dopod|PHILIPS|HAIER|LENOVO|MOT-|Nokia|SonyEricsson|SIE-|Amoi|ZTE/.test(navigator.userAgent))){if(window.location.href.indexOf("?mobile")<0){try{if(/Android|Windows Phone|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)){window.location.href="{dede:global.cfg_mobile/}{dede:type}[field:typeurl/]{/dede:type}";}else if(/iPad/i.test(navigator.userAgent)){}else{}}catch(e){}}}}</script>

内容页

<meta http-equiv="mobile-agent" content="format=xhtml;url={dede:global.cfg_mobile/}{dede:field.id runphp=yes}$result=GetOneArchive(@me);@me=$result['arcurl'];{/dede:field.id}">
<script type="text/javascript">if(window.location.toString().indexOf('pref=padindex') != -1){}else{if(/AppleWebKit.*Mobile/i.test(navigator.userAgent) || (/MIDP|SymbianOS|NOKIA|SAMSUNG|LG|NEC|TCL|Alcatel|BIRD|DBTEL|Dopod|PHILIPS|HAIER|LENOVO|MOT-|Nokia|SonyEricsson|SIE-|Amoi|ZTE/.test(navigator.userAgent))){if(window.location.href.indexOf("?mobile")<0){try{if(/Android|Windows Phone|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)){window.location.href="{dede:global.cfg_mobile/}{dede:field.id runphp=yes}$result=GetOneArchive(@me);@me=$result['arcurl'];{/dede:field.id}";}else if(/iPad/i.test(navigator.userAgent)){}else{}}catch(e){}}}}</script>

测试看看伪静态现在正常了么。

压缩包里面的手机模板都是默认的手机模板,如果出现样式问题或者是数据调用不出来。你可以按照下面的方法修改你的手机模板

css、js、images 改成绝对路径,例如 assets/css/ 改成 /assets/css/

index.php 改成 {dede:global.cfg_mobile/}

list.php?tid=[field:id/] 改成 [field:typelink/]

list.php?tid=~id~ 改成 ~typelink~

list.php?tid={dede:field name=’id’/} 改成 {dede:field.typeurl/}

view.php?aid=[field:id/] 改成 [field:arcurl/]

[field:litpic/] 改成 [field:global.cfg_basehost/][field:litpic/]

[field:image/] 改成 <img src=”[field:global.cfg_basehost/][field:litpic/]”>

上一页标签 {dede:prenext get=’pre’/}

改成

{dede:prenext get=pre runphp=yes}
$preurl = @me;
preg_match('/aid=(\d*)/',$preurl,$match);
$result = GetOneArchive($match[1]);
@me = !empty($result) ? "上一篇:<a href=\"{$result['arcurl']}\">{$result['title']}</a>" : "上一篇:没有了";
{/dede:prenext}

 

下一页标签 {dede:prenext get=’next’/}

改成

{dede:prenext get=next runphp=yes}
$preurl = @me;
preg_match('/aid=(\d*)/',$preurl,$match);
$result = GetOneArchive($match[1]);
@me = !empty($result) ? "下一篇:<a href=\"{$result['arcurl']}\">{$result['title']}</a>" : "下一篇:没有了";
{/dede:prenext}

 

文章内容 {dede:field.body/}改成

{dede:field.body runphp=yes}
global $cfg_basehost;
$str = @me;
$search = '/(<img.*?)width=(["\'])?.*?(?(2)\2|\s)([^>]+>)/is';
$search1 = '/(<img.*?)height=(["\'])?.*?(?(2)\2|\s)([^>]+>)/is';
$search2 = '#(<img.*?style=".*?)width:\d+px;([^"]*?.*?>)#i';
$search3 = '#(<img.*?style=".*?)height:\d+px;([^"]*?.*?>)#i';
$content = preg_replace($search,'$1$3',$str);
$content = preg_replace($search1,'$1$3',$content);
$content = preg_replace($search2,'$1$2',$content);
$content = preg_replace($search3,'$1$2',$content);
@me = $content;
@me = str_replace('/uploads/allimg/', $cfg_basehost.'/uploads/allimg/', $content);
{/dede:field.body}

 

栏目内容 {dede:field.content/}

改成

{dede:field.content runphp=yes}
global $cfg_basehost;
$str = @me;
$search = '/(<img.*?)width=(["\'])?.*?(?(2)\2|\s)([^>]+>)/is';
$search1 = '/(<img.*?)height=(["\'])?.*?(?(2)\2|\s)([^>]+>)/is';
$search2 = '#(<img.*?style=".*?)width:\d+px;([^"]*?.*?>)#i';
$search3 = '#(<img.*?style=".*?)height:\d+px;([^"]*?.*?>)#i';
$content = preg_replace($search,'$1$3',$str);
$content = preg_replace($search1,'$1$3',$content);
$content = preg_replace($search2,'$1$2',$content);
$content = preg_replace($search3,'$1$2',$content);
@me = $content;
@me = str_replace('/uploads/allimg/', $cfg_basehost.'/uploads/allimg/', $content);
{/dede:field.content}

注意:伪静态后,访问后台管理地址后面要加上index.php

织梦全站伪静态后台设置教程补充

上面的伪静态是在IIS下状态全部是正常的,但在NGINX下tags就显示404错误了。由于对正规则不太了解,网上查了好多教程,终于搞定,列表页,分页后面都带.html,上面教程里面不带.html

地址如下:

  • TAG标签页  http://www.tengtubz.com/tags/2018/
  • TAG标签分页 http://www.tengtubz.com/tags/2018/3/

这个在IIS运行环境下是显示正常的。但在NGINX下除TAG首页外,里面的链接都打不开的。

修改后的地址如下:

  • TAG标签页  http://www.tengtubz.com/tags/2018.html
  • TAG标签分页 http://www.tengtubz.com/tags/2018/3.html

修改方法:打开 \include\taglib\tag.lib.php ,大约在87行。

$row['link'] = $cfg_cmsurl."/tags.php?/".urlencode($row['keyword'])."/";

修改成:

$row['link'] = $cfg_cmsurl."/tags/".urlencode($row['keyword']).".html";

打开 \include\arc.taglist.class.php,大约在508行,要在地址后面加上.html

分页中间数字链接地址:

搜索:

$listdd.="<li><a href='".$purl."/$j/'>".$j."</a></li>\r\n";

替换成:

$listdd.="<li><a href='".$purl."/$j.html'>".$j."</a></li>\r\n";

分页首页链接地址:

搜索:

$indexpage="<li><a href='".$purl."/1/'>首页</a></li>\r\n";

替换成:

$indexpage="<li><a href='".$purl."/1.html'>首页</a></li>\r\n";

分页上一页链接地址:

搜索:

$prepage.="<li><a href='".$purl."/$prepagenum/'>上一页</a></li>\r\n";

替换成:

$prepage.="<li><a href='".$purl."/$prepagenum.html'>上一页</a></li>\r\n";

分页下一页链接地址:

搜索:

$nextpage.="<li><a href='".$purl."/$nextpagenum/'>下一页</a></li>\r\n";

替换成:

$nextpage.="<li><a href='".$purl."/$nextpagenum.html'>下一页</a></li>\r\n";

未页链接地址:

搜索:

$endpage="<li><a href='".$purl."/$totalpage/'>末页</a></li>\r\n";

替换成:

$endpage="<li><a href='".$purl."/$totalpage.html'>末页</a></li>\r\n";

如果你嫌上面一个一个的修改太麻烦,下面这个是关于除数字链接外其他分页链接修改过的源码,也就是

//获得上一页和下一页的链接和//获得数字链接之前的全部代码。

        //获得上一页和下一页的链接
        if($this->PageNo != 1)
        {
            $prepage.="<li><a href='".$purl."/$prepagenum.html'>上一页</a></li>\r\n";
            $indexpage="<li><a href='".$purl."/1.html'>首页</a></li>\r\n";
        }
        else
        {
            $indexpage="<li><a>首页</a></li>\r\n";
        }
        if($this->PageNo!=$totalpage && $totalpage>1)
        {
            $nextpage.="<li><a href='".$purl."/$nextpagenum.html'>下一页</a></li>\r\n";
            $endpage="<li><a href='".$purl."/$totalpage.html'>末页</a></li>\r\n";
        }
        else
        {
            $endpage="<li><a>末页</a></li>\r\n";
        }

        //获得数字链接

TAG伪静态规则如下

rewrite ^(.*)/tags\.html $1/tags.php;
rewrite ^(.*)/tags/(.*).html $1/tags.php?/$2;
rewrite ^(.*)/tags/(.*)\/([0-9])(?:(\?.*))\.html* $1/tags.php?\/$1\/$2;

织梦全站伪静态后台设置教程下载链接

百度云盘下载链接:https://pan.baidu.com/s/1qw7O8iE07U6PERysv3-kyw 密码: jhys

赞(4) 打赏
未经允许不得转载:广州SEO » 织梦DEDECMS全站目录化伪静态设置教程(电脑端+手机端)
分享到: 更多 (0)

评论 105

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
  1. #59

    I’m impressed, I have to admit. Seldeom do I come across a blog that’s equally educative and amusing, and let me tell you, you’ve
    hit the nail on the head. The problem is something which too few
    folks are speaking intelligently about. I’m very happy
    that I came across this in my search for something relating
    to this.

    Rhea7个月前 (01-31)回复
  2. #58

    Hello there! I could have sworn I’ve been to this website before but
    after reading through some of the post I realized it’s new to me.
    Anyways, I’m definitely glad I found it and I’ll be book-marking and checking
    back often!

    cialis buy online11个月前 (10-16)回复
  3. #57

    I’m very happy to uncover this website. I wanted to thank you for ones time due
    to this fantastic read!! I definitely really liked every little
    bit of it and I have you bookmarked to check out
    new stuff on your web site.

    Jefferson11个月前 (10-14)回复
  4. #56

    Wow, that’s what I was looking for, what a stuff! present here at
    this website, thanks admin of this website.

    Jacinto12个月前 (09-24)回复
  5. #55

    Wow! In tһe end I got a web site from wһere I know how to genyinely ɡet uѕeful іnformation concеrning mу study аnd knowledge.

    retrospective valuation strata unit when buying transfering1年前 (2019-08-20)回复
  6. #54

    Hello, yup this piece of writing is really nice and I have learned lot of things from
    it about blogging. thanks.

    huidspecialist1年前 (2019-04-26)回复
  7. #53

    Hi there to every body, it’s my first go to see of this weblog;
    this web site contains amazing and in fact
    excellent material in favor of visitors.

    minecraft1年前 (2019-04-25)回复
  8. #52

    Today, I went to the beachfront with my kids. I found a sea shell and
    gave it to my 4 year old daughter and said “You can hear the ocean if you put this to your ear.” She put the shell to her
    ear and screamed. There was a hermit crab inside and it pinched her ear.
    She never wants to go back! LoL I know this is entirely off topic but I
    had to tell someone!

    fun things for couples to do in bed1年前 (2019-04-24)回复
  9. #51

    Hi, Neat post. There is an issue along with your website in web explorer, might test this?
    IE nonetheless is the market chief and a good portion of other folks will miss your
    magnificent writing due to this problem.

    Golden Goose Superstar Zwart Kopen1年前 (2019-04-22)回复

专注于广州SEO优化推广,广州网站优化教程及网站推广

网站优化案例联系广州SEO

觉得SEO文章有用就打赏一下广州SEO

支付宝扫一扫打赏

微信扫一扫打赏