专注网站优化推广技术
提供网站优化排名服务

织梦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 = "http://www.verywen.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.verywen.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 = "http://m.verywen.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://m.verywen.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

赞(1) 打赏
原创SEO文章,作者:广州SEO,如若转载,请注明出处:https://www.360gzseo.com/31.html
分享到: 更多 (0)

评论 34

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

    Way cool! Some extremely valid points! I appreciate you penning this write-up and also the
    rest of the website is extremely good.

    situs judi online1个月前 (01-09)回复
  2. #17

    Tһat is а great tip partiсularⅼy to those new to the blogosphere.
    Brief but very precise info… Thanks for sharing this one.
    A mսst read article!

    Stockton Cremation2个月前 (01-01)回复
    • Thank you, welcome to learn SEO knowledge

      广州SEO1个月前 (01-14)回复
  3. #16

    Keep on writing, great job!

    11zuixin.com3个月前 (12-08)回复
  4. #15

    Hey! I know this is kinda off topic but I was wondering if you knew where I could locate a captcha plugin for my comment form?

    I’m using the same blog platform as yours and I’m having
    trouble finding one? Thanks a lot!

    vishnu laxmi3个月前 (12-07)回复
    • You can open it in the background, this is the function that comes with the program.

      广州SEO2个月前 (12-28)回复
  5. #14

    Hi my loved one! I want to say that this post is awesome, great written and come with approximately all vital infos.
    I’d like to see extra posts like this .

    Golden Goose Starter3个月前 (12-06)回复
  6. #13

    Nіce blog here! Also your web site loads up fast!
    Wһat weƅ host are you using? Can I geet your affiliate link to
    your host? I wish my site loaded uⲣ as fɑst as yours lol

    assHole3个月前 (12-05)回复
  7. #12

    I like the valuable info you provide in your articles. I’ll bookmark your weblog and check again here regularly.
    I am quite certain I’ll learn lots of new stuff right here!
    Best of luck for the next!

    Kaal Bhairav3个月前 (12-05)回复
    • Thank you for your appreciation, please also give me a lot of advice.

      广州SEO2个月前 (12-28)回复
  8. #11

    It’s fantastic that you are getting ideas from this post as well
    as from our discussion made at this place.

    Golden Goose Francy Homem Outlet3个月前 (12-05)回复
  9. #10

    Howdy! Would you mind if I share your blog with my twitter group?
    There’s a lot of people that I think would really enjoy your content.
    Please let me know. Many thanks

    Scarpe Isabel Marant Scontate Online3个月前 (12-05)回复
    • I don’t mind, thank you for your recognition, welcome to exchange and study together.

      广州SEO2个月前 (12-28)回复
  10. #9

    Hi i am kavin, its my first occasion to commenting anyplace, when i read this piece of writing i thought i
    could also make comment due to this sensible post.

    Mahabharat Story in Hindi3个月前 (12-04)回复
    • Thank you for sharing and learning SEO.

      广州SEO2个月前 (12-28)回复
  11. #8

    great points altogether, you simply gained a new reader.
    What could you recommend in regards to your post that you simply made a few days ago?

    Any sure?

    bookmarkok.Com3个月前 (12-04)回复
    • What information do you need to get about SEO?

      广州SEO2个月前 (12-28)回复
  12. #7

    Whаt’s up, I wіsh foг tߋ subscribe fߋr this blog tto get mоst rеcent updates, ѕo where
    can i ԁօ it рlease assist.

    http://www.musketeer-labs.com/comment/html/?5790.html3个月前 (12-04)回复
    • Yes, I appreciate you very much. If you can help more people solve the problems they encounter, you will also gain more knowledge.

      广州SEO2个月前 (12-28)回复
  13. #6

    Appreciation to my father who stated to me about this webpage, this blog is truly
    awesome.

    Dolores3个月前 (11-29)回复
    • Thank you for your recognition, welcome to learn SEO knowledge together.

      广州SEO2个月前 (12-28)回复
  14. #5

    Thanks a bunch for sharing this with all people you really recognise
    what you are talking approximately! Bookmarked.
    Please additionally seek advice from my website =). We may
    have a hyperlink trade contract between us

    http://11zuixin.com/3个月前 (11-25)回复
    • Thank you, welcome to learn and share SEO knowledge.

      广州SEO2个月前 (12-28)回复
  15. #4

    Do you mind if I quote a few of your posts as long as I provide
    credit and sources back to your website? My website is in the exact same niche as yours and my visitors would genuinely benefit from a lot of
    the information you present here. Please let me know if this ok with you.
    Many thanks!

    xmails3个月前 (11-25)回复
    • Hello, if you want to reprint my post, please pop my original text link for me, thank you

      广州SEO2个月前 (12-28)回复
  16. #3

    Hi there! Do you know if they make any plugins to help with Search Engine Optimization? I’m trying to get my blog
    to rank for some targeted keywords but I’m not seeing very good gains.
    If you know of any please share. Thank you!

    http://www.askspiritism.com/index.php?qa=16300&qa_1=internet-services-health-fraud-against-medical-practitioners3个月前 (11-23)回复
    • You can compare how other successful people do SEO keyword optimization and then learn where they are doing better.

      广州SEO2个月前 (12-28)回复
  17. #2

    Thanks for a marvelous posting! I genuinely enjoyed reading it, you can be a great author.

    I wll be sure to bookmark your blog and dfinitely
    will come back down the road. I want to encourage yourself
    to continue your great posts, have a nice afternoon!

    Software that manage my wordpress website3个月前 (11-23)回复
    • Thank you for reading, this is just my knowledge of learning SEO, and then share it with everyone to learn SEO.

      广州SEO2个月前 (12-28)回复
  18. #1

    I’m not positive the place you are getting your
    information, however good topic. I needs to spend some time finding
    out more or understanding more. Thanks for wonderful info I was looking for this information for my mission.

    Madrid3个月前 (11-22)回复

专注于广州SEO优化推广,提供广州网站优化教程及网站推广服务

网站优化案例联系SEO顾问

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

支付宝扫一扫打赏

微信扫一扫打赏