# 用户资料/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 年2 月 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:** 1\
**Showing post:** 3

<div class="post-metadata">

作者： ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)\
发布日期： [2026 年2 月 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)

---

_[View the full topic](https://meta.discourse.org/t/user-profiles-user-directory-in-robots-txt-x-robots-tag-header/395780)._
