出于测试目的,我正在尝试禁用所有访问我的开发服务器的web爬虫,使用robot.txt
当我在浏览器中输入127.0.0.1:8000/robot.txt时。为什么robot.txt没有出现在我的浏览器中?
Page not found (404)
127.0.0.1:8000/robot.txturls.py:
from django.http import HttpResponse
(r'^robots\.txt$', lambda r: HttpResponse("User-agent: *\nDisallow: /", mimetype="text/plain")),发布于 2013-06-16 02:45:43
您正在尝试访问robot.txt,而不是robots.txt。
您应该访问http://localhost/127.0.0.1:8000/robots.txt
发布于 2015-05-07 00:13:11
顺便说一下,它应该在urls.py中,而不是在views.py中。
如下所示:
from django.http import HttpResponse
urlpatterns = patterns('',
...
(r'^robots\.txt$', lambda r: HttpResponse("User-agent: *\nDisallow: /", mimetype="text/plain"))
)https://stackoverflow.com/questions/17126822
复制相似问题