時間:2023-08-05 01:36:01 | 來源:網(wǎng)站運(yùn)營
時間:2023-08-05 01:36:01 來源:網(wǎng)站運(yùn)營
輕松搞定Discuz!建站的sitemap.xml網(wǎng)站地圖問題(一):前段時間用DZ+三豐云的免費(fèi)云服務(wù)器搭建了一個寵物網(wǎng),服務(wù)器本身比較穩(wěn)定,但是發(fā)現(xiàn)了一個關(guān)于DZ的問題;DZ也算是老牌并且穩(wěn)定的建站系統(tǒng)了,但是它本身并不具備生成sitemap的功能,對于百度等搜索引擎的收錄有狠大的影響,DZ的應(yīng)用商城也有不少生成sitemap.xml網(wǎng)站地圖的插件,但是售價幾乎都是1、200元,這么簡單的一個功能也成了割韭菜的渠道,今天給大家分享兩種借助DZ后臺計劃任務(wù)就能輕松實現(xiàn)sitemap.xml網(wǎng)站地圖的生成方法。<?phpif(!defined('IN_DISCUZ')) {exit('Access Denied');}$filename='sitemap.xml';//以下五項根據(jù)具體情況修改即可$cfg_updateperi='60';//協(xié)議文件更新周期的上限,單位為分鐘$web_root=$_G['siteurl'];//根網(wǎng)址$CHARSET='utf-8';// or gbk //選擇編碼方式/***********************************************************************************************///網(wǎng)站地圖sitemap.xml$sitemap="<?xml version=/"1.0/" encoding=/"UTF-8/"?>/n";$sitemap.="<urlset/n";$sitemap.="xmlns=/"http://www.sitemaps.org/schemas/sitemap/0.9/"/n";$sitemap.="xmlns:xsi=/"http://www.w3.org/2001/XMLSchema-instance/"/n";$sitemap.="xsi:schemaLocation=/"http://www.sitemaps.org/schemas/sitemap/0.9/n";$sitemap.="http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd/">/n";$querys = DB::query("SELECT a.tid FROM ".DB::table('forum_thread')." a inner join ".DB::table('forum_forum')." b on a.fid=b.fid ORDER BY a.tid DESC LIMIT 0,10000");while($threadfid = DB::fetch($querys)){$turl=$web_root.'thread-'.$threadfid['tid'].'-1-1.html';//注意靜態(tài)規(guī)則$link = $turl;$t=time();$riqi=date("Y-m-d",$t);$priority=rand(1,10)/10;//date("D F d Y",$t);$sitemap.="<url>/n";$sitemap.="<loc>$link</loc>/n";$sitemap.="<priority>$priority</priority>/n";$sitemap.="<lastmod>$riqi</lastmod>/n";$sitemap.="<changefreq>weekly</changefreq>/n";$sitemap.="</url>/n";}$sitemap .= "</urlset>/n";$fp = fopen(DISCUZ_ROOT.'/'.$filename,'w');fwrite($fp,$sitemap);fclose($fp);?>
●上傳“cron_sitemap.php”到source/include/cron目錄;關(guān)鍵詞:地圖
客戶&案例
微信公眾號
版權(quán)所有? 億企邦 1997-2025 保留一切法律許可權(quán)利。