PHP robot.txt 的正确写法,robot 作为蜘蛛的遵守法则,里面有禁止拜访的路径,以及提供sitemap的路径,方便蜘蛛采集。
这里我仅仅提供zblog版本,其他自行参考!
例子如
User-agent: *
Disallow: /zb_users/
Disallow: /zb_system/
Disallow: /MemberCenter
Sitemap:https://www.meishi/sitemap_index.xml
Sitemap:https://www.meishih.com/sitemap.xml
<?php
header("Content-type: text/plain");
header('HTTP/1.1 200 OK');
$str = 'User-agent: *
Disallow: /zb_users/
Disallow: /zb_system/
Disallow: /MemberCenter
';
$str .= 'Sitemap:http://' . $_SERVER['SERVER_NAME'] . '/sitemap_index.xml';
$str .= 'Sitemap:http://' . $_SERVER['SERVER_NAME'] . '/sitemap.xml';
echo $str;
nginx 重定向 配置
rewrite ^/robots.txt$ /robots.php last;