zblog robots.txt的正确写法,php版本

2020-09-08  本文已影响0人  阿良_fc41

zblog robots.txt的正确写法,php版本,robots.txt作为网站的蜘蛛抓取遵循法则,里面可以自定义需要禁止的目录,以及sitemap的附属链接都可以添加

效果:

User-agent: *

Disallow: /zb_users/

Disallow: /zb_system/

Disallow: /MemberCenter

Sitemap:meishi/sitemap_index.xml

Sitemap:xx/sitemap.xml

语法就不多说Disallow 禁止,Allow 允许,Sitemap:地图

代码:

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;

上一篇 下一篇

猜你喜欢

热点阅读