美文网首页
zblog robots.txt的正确写法,php版本

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

作者: 阿良_fc41 | 来源:发表于2020-09-08 14:45 被阅读0次

    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;

    相关文章

      网友评论

          本文标题:zblog robots.txt的正确写法,php版本

          本文链接:https://www.haomeiwen.com/subject/cfadektx.html