Rails robots.txt folders

北慕城南 提交于 2019-12-04 09:03:59

问题


I'm about to launch a Rails app and as the last task, I wan't to set the robots.txt file. I couldn't find information about how the paths should be written properly for a Rails app.

Is the starting path always the root path from the Rails app or the app folder? How would I then disallow e.g. the img folder?

Do I have to write the paths as I see it in the app folder, or like how the paths look like on the site online, e.g. http://example.com/admin ?


回答1:


you have to put your robots.txt in /public folder

and it will look like in below

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

for more information please follow below links

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

and

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



来源:https://stackoverflow.com/questions/18693766/rails-robots-txt-folders

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!