【问题标题】:Rails robots.txt foldersRails robots.txt 文件夹
【发布时间】:2016-12-31 14:12:58
【问题描述】:

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

起始路径是否始终是 Rails 应用程序或应用程序文件夹的根路径?那么我将如何禁止例如img 文件夹?

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

【问题讨论】:

  • 这个问题似乎是题外话,因为它是关于 SEO

标签: ruby-on-rails robots.txt


【解决方案1】:

你必须把你的robots.txt 放在/public 文件夹中

如下图所示

以下示例“/robots.txt”文件指定任何机器人都不应访问以"/cyberworld/map/""/tmp/"/foo.html开头的任何URL:

# 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

欲了解更多信息,请点击以下链接

https://developers.google.com/webmasters/control-crawl-index/docs/robots_txt

http://www.robotstxt.org/robotstxt.html

【讨论】:

    猜你喜欢
    • 2016-09-16
    • 1970-01-01
    • 2017-08-10
    • 2013-01-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多