如何使用 Nginx 设置防止 XML 文件在 Rails 上被 Google 索引?

How to prevent XML files from indexing by Google on Rails with Nginx setup?

我在 Rails 和 Nginx 上设置了我的项目。如何防止站点地图 XML 文件开始被 Google 索引?

在您的虚拟主机文件中添加以下内容(需要该文件物理存在)

location ~* \.(txt|log|xml|css|js)$ {
    add_header X-Robots-Tag noindex;
}