ruby-on-rails - Ruby on Rails robots.txt 文件夹

标签 ruby-on-rails robots.txt

我即将启动 Ruby on Rails 应用程序,作为最后一项任务,我要设置 robots.txt 文件。我找不到有关如何为 Rails 应用程序正确编写路径的信息。

起始路径是否始终是 Ruby on Rails 应用程序或应用程序文件夹的根路径?我该如何禁止,例如 img 文件夹?

我是否必须按照在 app 文件夹中看到的方式编写路径,或者像路径在网站上的在线外观一样,例如http://example.com/admin

最佳答案

您必须将 robots.txt 文件放入 /public 文件夹中。

它可能看起来像 robotstxt.org 中的示例:

The following example "/robots.txt" file specifies that no robots should visit any URL starting with "/cyberworld/map/" or "/tmp/", or /foo.html:
# robots.txt for http://www.example.com/

User-agent: *
Disallow: /cyberworld/map/ # This is an infinite virtual URL space
Disallow: /tmp/ # these will soon disappear
Disallow: /foo.html

进一步阅读:

关于ruby-on-rails - Ruby on Rails robots.txt 文件夹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18693766/

相关文章:

ruby-on-rails - mongoId 的 activerecord 的 any_of 实现存在问题

ruby-on-rails - 将Bundler安装路径改成normal

ruby-on-rails - 在生产中禁用 GraphQL 自省(introspection)请求

wordpress - 我应该在 Google 网站站长工具中删除旧的 http 属性吗?

nginx - [NGINX]无法使 proxy_pass 和 robots.txt 工作

.htaccess - 如何在 robots.txt 或 .htaccess 上阻止某种类型的 url?

ruby-on-rails - 重命名表后,多个迁移的名称为 *

robots.txt 禁止除一个页面之外的所有页面?它们是否覆盖和级联?

plone - 如何在Plone中修改robots.txt?

ruby-on-rails - 在 Rails 3.2 中使用 Mongoid 时删除 database.yml