首先,使用百度搜索引擎 Ping
RPC2
服务功能来达到搜索引擎快速录音帖子(推荐)
实现原则:
根据百度网站管理员平台,网站程序可以自动提醒百度搜索引擎,包括您的网站并实时包含!
实施方法:
1.首先创建一个新文件,文件名是自定义的,放置 Discuz
的根目录! x
论坛!自定义名称的原因是虽然百度倡导着这个,但你不能重复它,虎屁股不会移动!所以改变名称,以免避免别人,你的电台 k
是尴尬的,你将不愿意!
我在这里暂定为:ping_
seo
.php
这在此处更改为您的网站地址(http
://bbs
.yeacome
.com
)。
使用此打开伪静态 ping
.php
代码:
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
;- }
- $
res
=postUrl
(‘http
://ping
.baidu
.com
/ping
/RPC2
’, $baiduXML
); - {
header
(“Location
:http
://bbs
.yeacome
.com
/thread
-$canshu
-1-1.html
”);- }
else
- {
header
(“Location
:http
://bbs
.yeacome
.com
/thread
-$canshu
-1-1.html
#”);- }
- ?>
- 复制代码
- 未启了伪静态的
ping
.php
代码用这个: 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
;- }
- $
res
=postUrl
(‘http
://ping
.baidu
.com
/ping
/RPC2
’, $baiduXML
); - {
- }
else
- {
- }
- ?>
- 复制代码
- 2、修改文件
source
\include
\post
\post_newthread
.php
, Discuz
X2
.0 找到- 复制代码
- 替换为(其中
ping_seo
为你自己的自定义ping
文件名称): showmessage
(‘post_newthread_succeed
’, “ping_seo
.php
?action
=$tid
”, $param
);- 复制代码
DZX2
.5 找到:showmessage
(‘post_newthread_succeed
’, $returnurl
, $values
, $param
);- 复制代码
- 替换为(其中
ping_seo
为你自己的自定义ping
文件名称): showmessage
(‘post_newthread_succeed
’, “ping
文件的文件名称.php
?action
=$tid
”, $values
, $param
);- 复制代码
OK
,简单两步完成,需要花冤枉钱么?Tips
:- 如果
PING
失败,那么你发新帖后跳转的网址最后面会有一个#号! - 测试是否
PING
成功,也可以访问http
://你的DZX
网址/ping
文件的文件名称.php
?action
=任意新帖子ID
,不成功的话,网址后面会有#号。 - 今天的教程就到这里,大家有什么疑问欢迎来提问。
转载请注明:汇站网 » discuz
教程:PING
快速实现百度秒收录