DedeCMS系統TAG標籤和分頁偽靜態怎麼設定?
現在好多CMS系統都有TAGS標籤這項功能,知名的DEDECMS也有,但是它的標籤功能很差,不利於seo優化,同時也有很多問題,比如:當前頁不存在上一頁時,鏈接為“-1”的問題,還有出現“系統無此標籤,可能已經移除」的問題。
推薦學習:織夢cms
今天小編就教大家把標籤偽靜態(部分資料來自網絡),同時也修復了一些上述提到的BUG。
1.修改前台顯示連結
我們這裡達到的效果就是讓原來/tags.php?keywors改為/tags/keywords.html。
這裡主要修改下呼叫的標籤,在/include/taglib/tag.lib.php中,在87行找到
$row['link'] = $cfg_cmsurl."/tags?".urlencode($row['keyword']);
將其改為:
$row['link'] = $cfg_cmsurl."/tags/".urlencode($row['keyword']).".html";
2.修改分頁程式碼部分
我們需要修改include/arc.taglist.class.php,找到分頁函數,將其替換為:
/** * 获取动态的分页列表 * * @access public * @param int $list_len 列表宽度 * @param string $listitem 列表样式 * @return string */ function GetPageListDM($list_len,$listitem="info,index,end,pre,next,pageno") { $prepage=""; $nextpage=""; $prepagenum = $this->PageNo - 1; $nextpagenum = $this->PageNo + 1; if($list_len == "" || preg_match("/[^0-9]/", $list_len)) { $list_len = 3; } $totalpage = $this->TotalPage; if($totalpage <= 1 && $this->TotalResult > 0) { return "<span class=\"pageinfo\">共1页/".$this->TotalResult."条</span>"; } if($this->TotalResult == 0) { return "<span class=\"pageinfo\">共0页/".$this->TotalResult."条</span>"; } $maininfo = "<span class=\"pageinfo\">共{$totalpage}页/".$this->TotalResult."条</span>\r\n"; $purl = $this->GetCurUrl(); $basename = basename($purl); $tmpname = explode('.', $basename); $purl = str_replace($basename, '', $purl).urlencode($this->Tag); //var_dump($purl);exit; //$purl .= "?/".urlencode($this->Tag); //获得上一页和下一页的链接 //if($this->PageNo != 1) 这是修正上一页为负数的问题 if($this->PageNo != 1 && $this->PageNo != "") { $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"; } //获得数字链接 $listdd=""; $total_list = $list_len * 2 + 1; if($this->PageNo >= $total_list) { $j = $this->PageNo - $list_len; $total_list = $this->PageNo + $list_len; if($total_list > $totalpage) { $total_list = $totalpage; } } else { $j=1; if($total_list > $totalpage) { $total_list = $totalpage; } } for($j; $j<=$total_list; $j++) { if($j == $this->PageNo) { $listdd.= "<li class=\"thisclass\"><a>$j</a></li>\r\n"; } else { $listdd.="<li><a href='".$purl."-$j.html'>".$j."</a></li>\r\n"; } } $plist = ''; if(preg_match('/info/i', $listitem)) { $plist .= $maininfo.' '; } if(preg_match('/index/i', $listitem)) { $plist .= $indexpage.' '; } if(preg_match('/pre/i', $listitem)) { $plist .= $prepage.' '; } if(preg_match('/pageno/i', $listitem)) { $plist .= $listdd.' '; } if(preg_match('/next/i', $listitem)) { $plist .= $nextpage.' '; } if(preg_match('/end/i', $listitem)) { $plist .= $endpage.' '; } return $plist; }
3.設定偽靜態規則
我們這裡以iis7為例子,設定以下規則:
<?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <rewrite> <rules> <rule name="weather1" stopProcessing="true"> <match url="tags/([^-]+)\.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?/{R:1}" appendQueryString="false" /> </rule> <rule name="weather2" 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?/{R:1}/{R:2}" appendQueryString="false" /> </rule> </rules> </rewrite> </system.webServer> </configuration>
以上是DedeCMS系統TAG標籤和分頁偽靜態怎麼設定的詳細內容。更多資訊請關注PHP中文網其他相關文章!

熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

AI Hentai Generator
免費產生 AI 無盡。

熱門文章

熱工具

SublimeText3漢化版
中文版,非常好用

Atom編輯器mac版下載
最受歡迎的的開源編輯器

VSCode Windows 64位元 下載
微軟推出的免費、功能強大的一款IDE編輯器

禪工作室 13.0.1
強大的PHP整合開發環境

DVWA
Damn Vulnerable Web App (DVWA) 是一個PHP/MySQL的Web應用程序,非常容易受到攻擊。它的主要目標是成為安全專業人員在合法環境中測試自己的技能和工具的輔助工具,幫助Web開發人員更好地理解保護網路應用程式的過程,並幫助教師/學生在課堂環境中教授/學習Web應用程式安全性。 DVWA的目標是透過簡單直接的介面練習一些最常見的Web漏洞,難度各不相同。請注意,該軟體中