📖SEO网站优化(3):网站TAG伪静态的设置

TAG伪静态

今天来讲一讲关于网站中TAG伪静态如何制作,为了迎合搜索引擎,方便搜索引擎蜘蛛来抓取网页上的相关内容,从而有利于优化网站搜索引擎喜欢收录静态页面

DEDETAG伪静态

1:修改 根目录下/include/taglib.php文件,将以下代码复制替换掉源代码

<?php
//function GetTags($num,$ltype='new',$InnerText='')
/**
 * TAG调用标签
 *
 * @version        $Id: tag.lib.php 1 9:29 2010年7月6日Z tianya $
 * @package        DedeCMS.Taglib
 * @copyright      Copyright (c) 2007 - 2010, DesDev, Inc.
 * @license        http://help.dedecms.com/usersguide/license.html
 * @link           http://www.dedecms.com
 */
 
/*>>dede>>
<name>TAG调用</name>
<type>全局标记</type>
<for>V55,V56,V57</for>
<description>TAG调用标签</description>
<demo>
{dede:tag sort='new' getall='0'}
<a href='[field:link/]'>[field:tag /]</a>
{/dede:tag}
</demo>
<attributes>
    <iterm>row:调用条数</iterm> 
    <iterm>sort:排序方式 month,rand,week</iterm>
    <iterm>getall:获取类型 0 为当前内容页TAG标记,1为获取全部TAG标记</iterm>
</attributes> 
>>dede>>*/
 
function lib_tag(&$ctag,&$refObj)
{
    global $dsql,$envs,$cfg_cmsurl;
    //属性处理
    $attlist="row|30,sort|new,getall|0,typeid|0";
    FillAttsDefault($ctag->CAttribute->Items,$attlist);
    extract($ctag->CAttribute->Items, EXTR_SKIP);

    $InnerText = $ctag->GetInnerText();
    if(trim($InnerText)=='') $InnerText = GetSysTemplets('tag_one.htm');
    $revalue = '';

    $ltype = $sort;
    $num = $row;

    $addsql = '';

    if($getall==0 && isset($refObj->Fields['tags']) && !empty($refObj->Fields['aid']))
    {
        $dsql->SetQuery("SELECT tid FROM `#@__taglist` WHERE aid = '{$refObj->Fields['aid']}' ");
        $dsql->Execute();
        $ids = '';
        while($row = $dsql->GetArray())
      {
          $ids .= ( $ids=='' ? $row['tid'] : ','.$row['tid'] );
        }
        if($ids != '')
        {
            $addsql = " WHERE id IN($ids) ";
        }
        if($addsql=='') return '';
    }
    else
    {
        if(!empty($typeid))
        {
            $addsql = " WHERE typeid='$typeid' ";
        }
  }
  
    if($ltype=='rand') $orderby = 'rand() ';
    else if($ltype=='week') $orderby=' weekcc DESC ';
    else if($ltype=='month') $orderby=' monthcc DESC ';
    else if($ltype=='hot') $orderby=' count DESC ';
    else if($ltype=='total') $orderby=' total DESC ';
    else $orderby = 'addtime DESC  ';

    $dsql->SetQuery("SELECT * FROM `#@__tagindex` $addsql ORDER BY $orderby LIMIT 0,$num");
    $dsql->Execute();

    $ctp = new DedeTagParse();
    $ctp->SetNameSpace('field','[',']');
    $ctp->LoadSource($InnerText);
    while($row = $dsql->GetArray())
    {
        $row['keyword'] = $row['tag'];
        $row['tag'] = dede_htmlspecialchars($row['tag']);
       $row['link'] = $cfg_cmsurl."/tags/".urlencode($row['keyword']).".html";
        $row['highlight'] = 0;
        if($row['monthcc']>1000 || $row['weekcc']>300 )
        {
            $row['highlight'] = mt_rand(3,4);
        }
        else if($row['count']>3000)
        {
            $row['highlight'] = mt_rand(5,6);
        }
        else
        {
            $row['highlight'] = mt_rand(1,2);
        }
        foreach($ctp->CTags as $tagid=>$ctag)
        {
            if(isset($row[$ctag->GetName()]))
            {
                $ctp->Assign($tagid,$row[$ctag->GetName()]);
            }
        }
        $revalue .= $ctp->GetResult();
    }
    return $revalue;
}

2:在网站伪静态中填写这个

location / {
rewrite "^/index.html$" /index.php last;
rewrite "^/list-([0-9]+)\.html$" /plus/list.php?tid=$1 last;
rewrite "^/list-([0-9]+)-([0-9]+)-([0-9]+)\.html$" /plus/list.php?tid=$1&totalresult=$2&PageNo=$3 last;
rewrite "^/view-([0-9]+)-1\.html$" /plus/view.php?arcID=$1 last;
rewrite "^/view-([0-9]+)-([0-9]+)\.html$" /plus/view.php?aid=$1&pageno=$2 last;
rewrite ^(.*)/tags\.html $1/tags.php;
rewrite ^(.*)/tags/(.*).html $1/tags.php?/$2;
}

帝国TAG伪静态

1:替换 根目录/e/class/connect.php 点击下载 提取码:8yqw
2:替换 根目录/e/tags/index.php 点击下载 提取码:fd3g
3:修改内部模板TAG调用方式

[e:loop={"select * from [!db.pre!]enewstags order by num DESC limit 30",0,24,0}]
     <?echo '<li><a href="/tags-'.urlencode($bqr['tagid']).'-0.html" >'.$bqr['tagname'].'</a></li>';?>
[/e:loop]

4:后台 – 系统设置 – 伪静态参数设置 – TAGS信息列表页 – 填入 tags-[!–tagname–]-[!–page–].html
5:站点伪静态设置

Apache 服务器:
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^listinfo-([0-9]+)-([0-9]+).html?(.*?)$ /e/action/ListInfo/index\.php\?classid=$1&page=$2
RewriteRule ^showinfo-([0-9]+)-([0-9]+)-([0-9]+).html?(.*?)$ /e/action/ShowInfo\.php\?classid=$1&id=$2&page=$3
RewriteRule ^search-([0-9]+)-([0-9]+).html?(.*?)$ /e/search/result/index\.php\?page=$1&searchid=$2
RewriteRule ^tags-(.+?)-([0-9]+).html$ /e/tags/index.php?tagname=$1&page=$2 [NC,L]
RewriteRule ^tags-(.*)-(.*)$ e/tags/index.php?tagid=$1&page=$2 [NC,L]

Nginx 服务器:
if ($args ~ "^(.*)$"){set $rule_0 1$rule_0;}
if ($rule_0 = "1"){rewrite ^/listinfo-([0-9]+)-([0-9]+).html?(.*?)$ /e/action/ListInfo/index\.php\?classid=$1&page=$2;}
	rewrite ^/showinfo-([0-9]+)-([0-9]+)-([0-9]+).html?(.*?)$ /e/action/ShowInfo\.php\?classid=$1&id=$2&page=$3;
	rewrite ^/search-([0-9]+)-([0-9]+).html?(.*?)$ /e/search/result/index\.php\?page=$1&searchid=$2;
	rewrite ^/tags-(.+?)-([0-9]+).html$ /e/tags/index.php?tagname=$1&page=$2 last;
	rewrite ^/tags-(.*)-(.*)$ /e/tags/index.php?tagid=$1&page=$2 last;

WordPressTAG伪静态

1:后台 – 设置- 固定链接设置为 /%category%/%post_id%.html
2:设置站点伪静态

Nginx 服务器:
location /
{
	 try_files $uri $uri/ /index.php?$args;
}

rewrite /wp-admin$ $scheme://$host$uri/ permanent;

结束语

根据上面的设置对最常用的3种CMS进行伪静态设置,至于TAG伪静态的好处随便百度一下就能知道了,我也就不多说了

标签

🧐发表评论

您必须启用javascript才能在此处查看验证码