Data+

Django에서 robots.txt 처리하기

by Qerogram
서론

로그를 보니 로봇이 특정 경로를 자꾸 수색하는 로그를 확인해서 찾아서 조치 해봤다.


진행과정


설정할 것은 총 2가지다.

urls.py에 이런 코드를 추가해주면 된다.

1
2
3
4
5
from django.views.generic import TemplateView
 
urlpatterns = [
    url(r'^robots.txt$', TemplateView.as_view(template_name="robots.txt", content_type="text/plain"), name="project_robots_file"),
]
cs


templates 폴더안에 robots.txt를 만들고. 아래와 같은, 수식을 쓰게되면 모든 로봇은 tmp, junk, cgi-bin 폴더에 접근 권한이 사라지는 것이다. 자세한 것은 레퍼런스를 참조하기 바란다.

User-agent: *
Disallow: /cgi-bin/
Disallow: /tmp/
Disallow: /junk/


# REF

http://ngee.tistory.com/949

https://ko.wikipedia.org/wiki/%EB%A1%9C%EB%B4%87_%EB%B0%B0%EC%A0%9C_%ED%91%9C%EC%A4%80

블로그의 정보

Data+

Qerogram

활동하기