国产三级农村妇女在线,国产精品毛片a∨一区二区三区,国产乱子伦视频大全,国产精品色拉拉,国产欧美日韩一区二区三区,

首頁(yè) > 技術(shù) > cms教程

discuz教程:PING快速實(shí)現(xiàn)百度秒收錄

小編 cms教程 2024-04-01 16:41:04
一、利用百度搜索引擎的PING RPC2服務(wù)功能來(lái)達(dá)到搜索引擎快速收錄帖子(推薦)
實(shí)現(xiàn)原理:
根據(jù)百度站長(zhǎng)平臺(tái)的提示,網(wǎng)站程序可以通過(guò)PING RPC2服務(wù)自動(dòng)提醒百度搜索引擎收錄你的網(wǎng)站,實(shí)時(shí)收錄的哦!
實(shí)現(xiàn)辦法:
1、首先新建一個(gè)新文件,文件名自定,放Discuz! X論壇的根目錄!要自定名字的原因是,雖然百度提倡這么干,但是你不能老重復(fù)的提交啊,老虎屁股動(dòng)不得!所以改名,以免別人搗蛋,你的站K了啥的,就別賴我了!
我這里暫定名為: ping_seo.php這里修改網(wǎng)址,將我的站點(diǎn)地址(http://bbs.yeacome.com)改為你的。
開啟了偽靜態(tài)的ping.php代碼用這個(gè):
if(isset($_GET['action']))
{
$canshu=$_GET['action'];
}
function postUrl($url, $postvar)
{
$ch = curl_init();
$headers = array(
"POST ".$url." HTTP/1.0",
"Content-type: text/xml; charset="utf-8"",
"Accept: text/xml",
"Content-length: ".strlen($postvar)
);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postvar);
$res = curl_exec ($ch);
curl_close ($ch);
return $res;
}
$baiduXML = "
weblogUpdates.extendedPing
易康論壇
http://bbs.yeacome.com/
http://bbs.yeacome.com/thread-$canshu-1-1.html
http://bbs.yeacome.com/forum.php?mod=rss
";
$res = postUrl('http://ping.baidu.com/ping/RPC2', $baiduXML);
if ( strpos($res, "0") )
{
header ("Location:http://bbs.yeacome.com/thread-$canshu-1-1.html");
}
else
{
header ("Location:http://bbs.yeacome.com/thread-$canshu-1-1.html#");
}
?>
復(fù)制代碼
未啟了偽靜態(tài)的ping.php代碼用這個(gè):
if(isset($_GET['action']))
{
$canshu=$_GET['action'];
}
function postUrl($url, $postvar)
{
$ch = curl_init();
$headers = array(
"POST ".$url." HTTP/1.0",
"Content-type: text/xml; charset="utf-8"",
"Accept: text/xml",
"Content-length: ".strlen($postvar)
);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postvar);
$res = curl_exec ($ch);
curl_close ($ch);
return $res;
}
$baiduXML = "
weblogUpdates.extendedPing
你的站名
http://你的DZX網(wǎng)址/
http://你的DZX網(wǎng)址 /forum.php?mod=viewthread&tid=$canshu
http://你的DZX網(wǎng)址/forum.php?mod=rss
";
$res = postUrl('http://ping.baidu.com/ping/RPC2', $baiduXML);
if ( strpos($res, "0") )
{
header ("Location:http://你的DZX網(wǎng)址/forum.php?mod=viewthread&tid=$canshu");
}
else
{
header ("Location:http://你的DZX網(wǎng)址/forum.php?mod=viewthread&tid=$canshu#");
}
?>
復(fù)制代碼
2、修改文件sourceincludepostpost_newthread.php,
Discuz X2.0找到
showmessage('post_newthread_succeed', "forum.php?mod=viewthread&tid=$tid&extra=$extra", $param);
復(fù)制代碼
替換為(其中ping_seo為你自己的自定義ping文件名稱):
showmessage('post_newthread_succeed', "ping_seo.php?action=$tid", $param);
復(fù)制代碼
DZX2.5找到:
showmessage('post_newthread_succeed', $returnurl, $values, $param);
復(fù)制代碼
替換為(其中ping_seo為你自己的自定義ping文件名稱):
showmessage('post_newthread_succeed', "ping文件的文件名稱.php?action=$tid", $values, $param);
復(fù)制代碼
OK,簡(jiǎn)單兩步完成,需要花冤枉錢么?
Tips:
如果PING失敗,那么你發(fā)新帖后跳轉(zhuǎn)的網(wǎng)址最后面會(huì)有一個(gè)#號(hào)!
測(cè)試是否PING成功,也可以訪問(wèn)http://你的DZX網(wǎng)址/ping文件的文件名稱.php?action=任意新帖子ID,不成功的話,網(wǎng)址后面會(huì)有#號(hào)。
今天的教程就到這里,大家有什么疑問(wèn)歡迎來(lái)提問(wèn)。

TAg

加載中~

本網(wǎng)站LOGO受版權(quán)及商標(biāo)保護(hù),版權(quán)登記號(hào):國(guó)作登字-2022-F-10126915,未經(jīng)湖南木星科技官方許可,嚴(yán)禁使用。
Copyright ? 2012-2022 湖南木星科技有限公司(木星網(wǎng))版權(quán)所有
轉(zhuǎn)載內(nèi)容版權(quán)歸作者及來(lái)源網(wǎng)站所有,本站原創(chuàng)內(nèi)容轉(zhuǎn)載請(qǐng)注明來(lái)源,商業(yè)媒體及紙媒請(qǐng)先聯(lián)系:aishangyiwan@126.com

工信部備案號(hào):湘ICP備19012813號(hào)-5