# 用户资料/robots.txt中的用户目录/x-robots-tag 标头

**URL:** <https://meta.discourse.org/t/user-profiles-user-directory-in-robots-txt-x-robots-tag-header/395780>\
**Category:** Bug\
**Created:** [2026年二月11日 10:58 UTC](https://meta.discourse.org/t/user-profiles-user-directory-in-robots-txt-x-robots-tag-header/395780 "2026-02-11T10:58:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)\
**Post date:** [2026年二月11日 10:58 UTC](https://meta.discourse.org/t/user-profiles-user-directory-in-robots-txt-x-robots-tag-header/395780/1 "2026-02-11T10:58:51Z")

</div>

编辑：这原来是一个错误，请参见第 3 楼

如果勾选了“向公众隐藏用户资料”，那么在 robots.txt 中不应该禁止 `/u` 吗？  
否则搜索引擎会遇到 403 错误，这可能会影响排名和可见性。

这据称是在 2014 年实现的 [Excluding user profiles in robots.txt (or allow edit of file) - #2 by neil](https://meta.discourse.org/t/excluding-user-profiles-in-robots-txt-or-allow-edit-of-file/15886/2) [Disallow /users/ in robots.txt · discourse/discourse@8267a45 · GitHub](https://github.com/discourse/discourse/commit/8267a451b25c596c88919ccd3bc96b5b3a564c5d)

我能找到的唯一在 robots.txt 中包含 `Disallow: /u` 的 Discourse 论坛是 Meta আশ্চর্যজনক:

---

<div class="post-metadata">

**Author:** ![Moin](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/moin/32/554653_2.png) [@Moin](https://meta.discourse.org/u/Moin)\
**Post date:** [2026年二月11日 11:02 UTC](https://meta.discourse.org/t/user-profiles-user-directory-in-robots-txt-x-robots-tag-header/395780/2 "2026-02-11T11:02:24Z")

</div>

> [@RGJ](#):
>
> 我能找到的唯一一个有 `Disallow: /u` 的 Discourse 论坛是 Meta 🤔

也许 Meta 被定制过，所以跳过了 [FIX: Remove /u/ from robots by nattsw · Pull Request #30782 · discourse/discourse · GitHub](https://github.com/discourse/discourse/pull/30782) 中的迁移

---

<div class="post-metadata">

**Author:** ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)\
**Post date:** [2026年二月11日 11:22 UTC](https://meta.discourse.org/t/user-profiles-user-directory-in-robots-txt-x-robots-tag-header/395780/3 "2026-02-11T11:22:26Z")

</div>

找得好 @Moin

> 目前，我们已经在 `/u` 路由中添加了 `noindex`。然而，由于 robots.txt 屏蔽了这些页面，搜索引擎无法看到该头部信息。

所以，这指向了之前的一个更改 [FIX: Always noindex /u routes - Pull Request #27712 - discourse/discourse - GitHub](https://github.com/discourse/discourse/pull/27712)

其中提到

> 其次，`SiteSetting.hide_user_profiles_from_public` 会抛出 `Forbidden` 异常，这导致我们的 `after_action: add no index header` 无法触发。

> 此 PR 确保通过 `before_action` 添加 noindex 头部信息。我们可能会考虑从
> 
> [discourse/app/controllers/robots\_txt\_controller.rb](https://github.com/discourse/discourse/blob/2900cbefe10930173d4b29a8d2b69e85b574ddd3/app/controllers/robots_txt_controller.rb#L24)
> 
> 2900cbe 中的第 24 行
> 
> DISALLOWED\_WITH\_HEADER\_PATHS = %w[/badges /u/ /my /search /tag/_/l /g /t/_/_.rss /c/_.rss]

不幸的是，这并不总是有效。虽然 `/u/rgj` 确实有 `x-robots-tag: noindex` 头部，但 `/u/rgj/summary` 却没有，所以看起来最近的更改产生了一些不想要的副作用。

(移至 #Contribute > Bug)
