镖师 发表于 2023-8-11 07:38:00

请问如何禁谷歌和必应的蜘蛛搜索引擎

必应每天都有几千个爬行记录,就是老爬个人资料


robots.txt我这样写对么,大佬帮纠正一下

#
# robots.txt for Discuz! X3
#

User-agent: *
Allow: /data/attachment/
Allow: /data/cache/
Allow: /uc_server/data/avatar/
Disallow: /api/
Disallow: /data/
Disallow: /source/
Disallow: /install/
Disallow: /template/default/
Disallow: /config/
Disallow: /uc_client/
Disallow: /uc_server/
Disallow: /admin.php
Disallow: /search.php
Disallow: /member.php
Disallow: /api.php
Disallow: /misc.php
Disallow: /connect.php
Disallow: /forum.php?mod=redirect*
Disallow: /forum.php?mod=post*
Disallow: /*?mod=misc*
Disallow: /*?mod=attachment*
Disallow: /*mobile=yes*
Disallow: */home
Disallow: */home.php?mod=spacecp*
Disallow: */home.php?mod=profile*

User-agent: Googlebot
Disallow: /

User-agent: bingbot
Disallow: /

User-agent: manbot
Disallow: /

我知道答案 回答被采纳将会获得1 贡献 已有0人回答

Discuz智能体 发表于 2025-3-16 18:57:58

根据您的需求,建议按以下方式优化robots.txt规则:

User-agent: *
Allow: /data/attachment/
Allow: /data/cache/
Allow: /uc_server/data/avatar/
Disallow: /api/
Disallow: /data/
Disallow: /source/
Disallow: /install/
Disallow: /template/default/
Disallow: /config/
Disallow: /uc_client/
Disallow: /uc_server/
Disallow: /admin.php
Disallow: /search.php
Disallow: /member.php*
Disallow: /api.php
Disallow: /misc.php
Disallow: /connect.php
Disallow: /forum.php?mod=redirect*
Disallow: /forum.php?mod=post*
Disallow: /*?mod=misc*
Disallow: /*?mod=attachment*
Disallow: /*mobile=yes*
Disallow: /home.php?mod=spacecp*
Disallow: /home.php?mod=profile*
Disallow: /home.php?mod=space&*

# 特别屏蔽规则
User-agent: Googlebot
Disallow: /home.php?mod=space
Disallow: /home.php?mod=profile
Disallow: /home.php?mod=spacecp

User-agent: bingbot
Disallow: /home.php?mod=space
Disallow: /home.php?mod=profile
Disallow: /home.php?mod=spacecp

User-agent: MJ12bot
Disallow: /

优化说明:

1. 强化个人资料屏蔽:
- 使用`/home.php?mod=space*`拦截所有用户空间页面
- 增加`/member.php*`禁止所有会员相关页面
- 参数路径改用&号通配符`/home.php?mod=space&*`更精确匹配

2. 增强特定引擎限制:
- 单独设置Googlebot/bingbot规则,三重拦截profile/spacecp/space页面
- 保留全局规则的同时,针对特定蜘蛛追加更严格限制

3. 推荐配套措施:
(1) 后台SEO设置:在Discuz!后台 » SEO设置 » 其他 » "禁止访问的蜘蛛" 填入:
Googlebot
bingbot
YisouSpider

(2) Nginx防护配置(在server块内添加):
if ($http_user_agent ~* (googlebot|bingbot|yisou)) {
    rewrite ^/(home|member).php /403.html last;
}

(3) 模板层防护:在个人资料模板(通常为`template/default/home/space_profile.htm`)头部添加:
<meta name="robots" content="noindex,nofollow,noarchive">

注意事项:
1. 修改后建议通过DZ插件网的验证语法有效性
2. 屏蔽生效存在48小时左右的延迟期
3. 定期在网站日志中搜索"bingbot"确认屏蔽效果
4. 对已收录的个人资料页面可通过DZ插件网的[死链提交工具]加速清理

如果仍发现异常爬取,可考虑安装「蜘蛛防御系统」插件,该插件具备:
- 实时蜘蛛行为分析
- 动态验证码拦截
- 高频访问自动封禁
- 详细爬取日志记录
等功能,能有效遏制恶意爬虫。
-- 本回答由 人工智能 AI智能体 生成,内容仅供参考,请仔细甄别。

Discuz智能体 发表于 2025-3-21 06:20:39

你好!你提供的 `robots.txt` 文件内容大部分是正确的,但有一些地方可以优化。以下是一些建议:

1. **禁止特定搜索引擎爬取**:
   你已经正确地使用了 `User-agent` 来指定特定的搜索引擎爬虫(如 `Googlebot` 和 `bingbot`),并且使用 `Disallow: /` 来禁止它们爬取整个网站。这部分是正确的。

2. **优化 `robots.txt` 文件**:
   - 你可以将 `User-agent: *` 的部分放在文件的最前面,这样可以让所有爬虫先看到通用的规则。
   - 你可以将 `Allow` 和 `Disallow` 的规则合并,以减少文件的行数。

3. **禁止爬取个人资料页面**:
   你已经正确地禁止了爬虫访问个人资料页面(如 `*/home.php?mod=spacecp*` 和 `*/home.php?mod=profile*`),这部分也是正确的。

4. **其他建议**:
   - 如果你只想禁止特定的搜索引擎爬取某些页面,而不是整个网站,你可以将 `Disallow: /` 改为具体的路径。例如,如果你只想禁止 `Googlebot` 和 `bingbot` 爬取个人资料页面,可以这样写:

User-agent: Googlebot
Disallow: */home.php?mod=spacecp*
Disallow: */home.php?mod=profile*

User-agent: bingbot
Disallow: */home.php?mod=spacecp*
Disallow: */home.php?mod=profile*

5. **最终优化后的 `robots.txt` 文件**:

#
# robots.txt for Discuz! X3
#

User-agent: *
Allow: /data/attachment/
Allow: /data/cache/
Allow: /uc_server/data/avatar/
Disallow: /api/
Disallow: /data/
Disallow: /source/
Disallow: /install/
Disallow: /template/default/
Disallow: /config/
Disallow: /uc_client/
Disallow: /uc_server/
Disallow: /admin.php
Disallow: /search.php
Disallow: /member.php
Disallow: /api.php
Disallow: /misc.php
Disallow: /connect.php
Disallow: /forum.php?mod=redirect*
Disallow: /forum.php?mod=post*
Disallow: /*?mod=misc*
Disallow: /*?mod=attachment*
Disallow: /*mobile=yes*
Disallow: */home
Disallow: */home.php?mod=spacecp*
Disallow: */home.php?mod=profile*

User-agent: Googlebot
Disallow: /

User-agent: bingbot
Disallow: /

User-agent: manbot
Disallow: /

这样写可以确保 `Googlebot` 和 `bingbot` 不会爬取你的网站,同时其他爬虫仍然可以访问你允许的页面。

如果你有其他问题或需要进一步的帮助,请随时联系我!
-- 本回答由 人工智能 AI智能体 生成,内容仅供参考,请仔细甄别。
页: [1]
查看完整版本: 请问如何禁谷歌和必应的蜘蛛搜索引擎