robots.txt文件的格式

robots文件往往放置于根目录下,包含一条或更多的记录,这些记录通过空行分开(以CR,CR/NL,orNL作为结束符),每一条记录的格式如下所示:
"<field>:<optionalspace><value><optionalspace>"

在该文件中可以使用#进行注解,具体使用方法和UNIX中的惯例一样。该文件中的记录通常以一行或多行User-agent开始,后面加上若干Disallow和Allow行,详细情况如下:

User-agent:

该项的值用于描述搜索引擎robot的名字。在"robots.txt"文件中,如果有多条User-agent记录说明有多个robot会受到"robots.txt"的限制,对该文件来说,至少要有一条User-agent记录。如果该项的值设为*,则对任何robot均有效,在"robots.txt"文件中,"User-agent:*"这样的记录只能有一条。如果在"robots.txt"文件中,加入"User-agent:SomeBot"和若干Disallow、Allow行,那么名为"SomeBot"只受到"User-agent:SomeBot"后面的Disallow和Allow行的限制。

Disallow:

该项的值用于描述不希望被访问的一组URL,这个值可以是一条完整的路径,也可以是路径的非空前缀,以Disallow项的值开头的URL不会被robot访问。例如"Disallow:/help"禁止robot访问/help.html、/helpabc.html、/help/index.html,而"Disallow:/help/"则允许robot访问/help.html、/helpabc.html,不能访问/help/index.html。"Disallow:"说明允许robot访问该网站的所有url,在"/robots.txt"文件中,至少要有一条Disallow记录。如果"/robots.txt"不存在或者为空文件,则对于所有的搜索引擎robot,该网站都是开放的。

Allow:

该项的值用于描述希望被访问的一组URL,与Disallow项相似,这个值可以是一条完整的路径,也可以是路径的前缀,以Allow项的值开头的URL是允许robot访问的。例如"Allow:/hibaidu"允许robot访问/hibaidu.htm、/hibaiducom.html、/hibaidu/com.html。一个网站的所有URL默认是Allow的,所以Allow通常与Disallow搭配使用,实现允许访问一部分网页同时禁止访问其它所有URL的功能。

使用"*"and"$":Baiduspider支持使用通配符"*"和"$"来模糊匹配url。
"*"匹配0或多个任意字符

"$"匹配行结束符。

最后需要说明的是:百度会严格遵守robots的相关协议,请注意区分您不想被抓取或收录的目录的大小写,百度会对robots中所写的文件和您不想被抓取和收录的目录做精确匹配,否则robots协议无法生效。


联系电话:
1585150508*
QQ交谈:
小编
站长微信:
站长邮箱: service@qingjiuzhubei.com
38.05msRequest Duration2MBMemory UsageGET seoSchool/detail{id?}.htmlRouteAuth status
    • Booting (11.09ms)
    • Application (28.84ms)
      6 templates were rendered
      • site.zixun.seoDetail (resources/views/site/zixun/seoDetail.blade.php)9blade
        Params
        0
        cateAlls
        1
        newDetail
        2
        comment
        3
        hotnews
        4
        zuixinNews
        5
        xiangguan
        6
        t
        7
        d
        8
        k
      • layouts.site.layout (resources/views/layouts/site/layout.blade.php)21blade
        Params
        0
        obLevel
        1
        __env
        2
        app
        3
        device
        4
        isMobile
        5
        errors
        6
        cateAlls
        7
        newDetail
        8
        comment
        9
        hotnews
        10
        zuixinNews
        11
        xiangguan
        12
        t
        13
        d
        14
        k
        15
        __empty_1
        16
        __currentLoopData
        17
        hotnewsVal
        18
        loop
        19
        new
        20
        cateAll
      • layouts.site.top (resources/views/layouts/site/top.blade.php)21blade
        Params
        0
        obLevel
        1
        __env
        2
        app
        3
        device
        4
        isMobile
        5
        errors
        6
        cateAlls
        7
        newDetail
        8
        comment
        9
        hotnews
        10
        zuixinNews
        11
        xiangguan
        12
        t
        13
        d
        14
        k
        15
        __empty_1
        16
        __currentLoopData
        17
        hotnewsVal
        18
        loop
        19
        new
        20
        cateAll
      • layouts.site.bottom (resources/views/layouts/site/bottom.blade.php)21blade
        Params
        0
        obLevel
        1
        __env
        2
        app
        3
        device
        4
        isMobile
        5
        errors
        6
        cateAlls
        7
        newDetail
        8
        comment
        9
        hotnews
        10
        zuixinNews
        11
        xiangguan
        12
        t
        13
        d
        14
        k
        15
        __empty_1
        16
        __currentLoopData
        17
        hotnewsVal
        18
        loop
        19
        new
        20
        cateAll
      • common.upgrade_vip (resources/views/common/upgrade_vip.blade.php)21blade
        Params
        0
        obLevel
        1
        __env
        2
        app
        3
        device
        4
        isMobile
        5
        errors
        6
        cateAlls
        7
        newDetail
        8
        comment
        9
        hotnews
        10
        zuixinNews
        11
        xiangguan
        12
        t
        13
        d
        14
        k
        15
        __empty_1
        16
        __currentLoopData
        17
        hotnewsVal
        18
        loop
        19
        new
        20
        cateAll
      • kefu.kefu (resources/views/kefu/kefu.blade.php)21blade
        Params
        0
        obLevel
        1
        __env
        2
        app
        3
        device
        4
        isMobile
        5
        errors
        6
        cateAlls
        7
        newDetail
        8
        comment
        9
        hotnews
        10
        zuixinNews
        11
        xiangguan
        12
        t
        13
        d
        14
        k
        15
        __empty_1
        16
        __currentLoopData
        17
        hotnewsVal
        18
        loop
        19
        new
        20
        cateAll
      uri
      GET seoSchool/detail{id?}.html
      middleware
      web
      controller
      App\Http\Controllers\Site\ZixunController@seoSchoolDetail
      namespace
      App\Http\Controllers
      prefix
      /seoSchool
      where
      as
      seoSchoolDetail
      file
      app/Http/Controllers/Site/ZixunController.php:197-230
      8 statements were executed15.74ms
      • select * from `new_cates` where `pid` = '3' and `new_cates`.`deleted_at` is null1.84ms/app/Http/Controllers/Site/ZixunController.php:202zzshuju
        Metadata
        Bindings
        • 0. 3
        Hints
        • Use SELECT * only if you need all columns from table
        Backtrace
        • 12. /app/Http/Controllers/Site/ZixunController.php:202
        • 20. /vendor/silber/page-cache/src/Middleware/CacheResponse.php:38
        • 54. /public/index.php:53
      • select * from `news` where `news`.`id` = '25822' and `news`.`deleted_at` is null limit 1490μs/app/Http/Controllers/Site/ZixunController.php:203zzshuju
        Metadata
        Bindings
        • 0. 25822
        Hints
        • Use SELECT * only if you need all columns from table
        • LIMIT without ORDER BY causes non-deterministic results, depending on the query execution plan
        Backtrace
        • 14. /app/Http/Controllers/Site/ZixunController.php:203
        • 22. /vendor/silber/page-cache/src/Middleware/CacheResponse.php:38
        • 56. /public/index.php:53
      • select * from `new_cates` where `new_cates`.`id` in ('135') and `new_cates`.`deleted_at` is null320μs/app/Http/Controllers/Site/ZixunController.php:203zzshuju
        Metadata
        Bindings
        • 0. 135
        Hints
        • Use SELECT * only if you need all columns from table
        Backtrace
        • 19. /app/Http/Controllers/Site/ZixunController.php:203
        • 27. /vendor/silber/page-cache/src/Middleware/CacheResponse.php:38
        • 61. /public/index.php:53
      • select * from `news` where `news`.`deleted_at` is null order by `id` desc limit 10900μs/app/Http/Controllers/Site/ZixunController.php:205zzshuju
        Metadata
        Hints
        • Use SELECT * only if you need all columns from table
        Backtrace
        • 12. /app/Http/Controllers/Site/ZixunController.php:205
        • 20. /vendor/silber/page-cache/src/Middleware/CacheResponse.php:38
        • 54. /public/index.php:53
      • select * from `news` where `news`.`deleted_at` is null order by `published_at` desc limit 10950μs/app/Http/Controllers/Site/ZixunController.php:206zzshuju
        Metadata
        Hints
        • Use SELECT * only if you need all columns from table
        Backtrace
        • 12. /app/Http/Controllers/Site/ZixunController.php:206
        • 20. /vendor/silber/page-cache/src/Middleware/CacheResponse.php:38
        • 54. /public/index.php:53
      • select * from `news` where `newscate_id` = '135' and `news`.`deleted_at` is null order by `id` asc limit 105.57ms/app/Http/Controllers/Site/ZixunController.php:208zzshuju
        Metadata
        Bindings
        • 0. 135
        Hints
        • Use SELECT * only if you need all columns from table
        Backtrace
        • 12. /app/Http/Controllers/Site/ZixunController.php:208
        • 20. /vendor/silber/page-cache/src/Middleware/CacheResponse.php:38
        • 54. /public/index.php:53
      • update `news` set `browse` = `browse` + 1, `updated_at` = '2025-08-24 00:55:09' where `id` = '25822' and `news`.`deleted_at` is null5.19ms/app/Http/Model/News/News.php:170zzshuju
        Metadata
        Bindings
        • 0. 2025-08-24 00:55:09
        • 1. 25822
        Backtrace
        • 12. /app/Http/Model/News/News.php:170
        • 13. /app/Http/Controllers/Site/ZixunController.php:210
        • 21. /vendor/silber/page-cache/src/Middleware/CacheResponse.php:38
        • 55. /public/index.php:53
      • select * from `comments` where `news_id` = '25822'480μs/app/Http/Controllers/Site/ZixunController.php:214zzshuju
        Metadata
        Bindings
        • 0. 25822
        Hints
        • Use SELECT * only if you need all columns from table
        Backtrace
        • 12. /app/Http/Controllers/Site/ZixunController.php:214
        • 20. /vendor/silber/page-cache/src/Middleware/CacheResponse.php:38
        • 54. /public/index.php:53
        web
        array:2 [ "name" => "Guest" "user" => array:1 [ "guest" => true ] ]
        api
        array:2 [ "name" => "Guest" "user" => array:1 [ "guest" => true ] ]
          _token
          kO9rvnHvkqYcxADIaDeERwkKk9uTHqHDp0RGBU8e
          _previous
          array:1 [ "url" => "https://data.winndoo.cn/seoSchool/detail25822.html" ]
          PHPDEBUGBAR_STACK_DATA
          []
          format
          html
          content_type
          text/html; charset=UTF-8
          status_text
          OK
          status_code
          200
          request_query
          []
          request_request
          []
          request_headers
          array:17 [ "accept-encoding" => array:1 [ 0 => "gzip, deflate, br, zstd" ] "sec-ch-ua-plat...
          request_server
          array:41 [ "USER" => "apache" "HOME" => "/usr/share/httpd" "HTTP_ACCEPT_ENCODING" => "gzip, de...
          request_cookies
          []
          response_headers
          array:5 [ "cache-control" => array:1 [ 0 => "no-cache, private" ] "date" => array:1 [ ...
          path_info
          /seoSchool/detail25822.html
          session_attributes
          array:3 [ "_token" => "kO9rvnHvkqYcxADIaDeERwkKk9uTHqHDp0RGBU8e" "_previous" => array:1 [ "u...