Apache/nginx/IIS/dedecms dream weaving tag pseudo-static configuration rules

The tag tag of dedecms is a good function to manage keywords. You can find relevant keyword content through tag tags, so how to make TAGS static

1. Find tags.php in the dedecms program directory. Open the code found from $PageNo=1 to exit(); (as shown below). Replace these codes with the following code:

//tag伪静态

$tagid = (isset($tagid) && is_numeric($tagid)) ? $tagid : 0;

$PageNo = (isset($PageNo) && is_numeric($PageNo)) ? $PageNo : 1;

if ($tagid =="0") {

$dlist = new TagList($tag, 'tag.htm');

$dlist->Display();}

else{$row = $dsql->GetOne("SELECT tag FROM `tagindex` WHERE id ={$tagid}");

if (!is_array($row)) {ShowMsg('系统无此tag', '-1');

exit();}

$tag = FilterSearch($row['tag']);

$dlist = new TagList($tag, 'taglist.htm');

$dlist->Display();}

exit();

 

2. Modify the paging code. Also open include/arc.taglist.class.php and find // get the link to the previous page and the next page. Replace the paging function between //Get the link of the previous page and the next page to //Get the number link with the following functions: 2. TAG calls the tag. Open the include/taglib/tag.lib.php file and find the $row['link'] =$cfg_cmsurl."/tags.php?/".urlencode($row['keyword'])."/"; code. Replace it with $row['link'] = "/tags/{$row['id']}.html"; (Note that the symbols are all in English, not Chinese. Otherwise, it will not be found and the modification will be unsuccessful)

if($this->PageNo != 1)

{

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

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

}

else

{

$indexpage="<li><a>首页</a></li>\r\n";

}

if($this->PageNo!=$totalpage && $totalpage>1)

{

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

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

}

else

{

$endpage="<li><a>末页</a></li>\r\n";  }

RewriteEngine on4, set pseudo-static rules. Create a new txt text and add the following pseudo-static rules in the text. Then save it as .htaccess and upload it to the root directory of the website (if there is a pseudo-static file .htaccess, then do not overwrite .htaccess. Just open it and add the following rules to save it.)

Pseudo-static rules of dedecms tags under Apache

RewriteBase /

RewriteRule ^tags/([0-9]+)_([0-9]+).html$        tags.php?tagid=$1&PageNo=$2 [L]

RewriteRule ^tags/([0-9]+).html$                tags.php?tagid=$1 [L]

Note If the pseudo-static generation is successful, but the 404 page appears when accessing the dream, the pseudo-static rules are not set up, you need to write the corresponding rules according to your own website operating environment iis nginx apache

Pseudo-static rules of dedecms tags under nginx

rewrite "^/tags/([0-9]+).html$" /tags.php?tagid=$1 last;
rewrite "^/tags/([0-9]+)_([0-9]+).html$" /tags.php?tagid=$1&PageNo=$2 last;


Pseudo-static rules of dedecms tags under IIS (web.config)

<configuration>
 
    <system.webServer>
 
        <rewrite>
 
            <rules>
 
                <rule name="weather1" stopProcessing="true">
 
                    <match url="tags/([0-9]+).html$" ignoreCase="true" />
 
                    <conditions logicalGrouping="MatchAll">
 
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
 
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
 
                    </conditions>
 
                    <action type="Rewrite" url="/tags.php?tagid=$1" appendQueryString="false" />
 
                </rule>
 
                <rule name="weather2" stopProcessing="true">
 
                    <match url="tags/([0-9]+)_([0-9]+).html$" ignoreCase="true" />
 
                    <conditions logicalGrouping="MatchAll">
 
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
 
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
 
                    </conditions>
 
                    <action type="Rewrite" url="/tags.php?tagid=$1&PageNo=$2" appendQueryString="false" />

                </rule>
 
            </rules>
 
        </rewrite>
 
    </system.webServer>
 
</configuration>

Guess you like

Origin blog.csdn.net/qq_39339179/article/details/109806174