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/
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
'코딩 > Python' 카테고리의 다른 글
#7. Django에 SSL 달아주기 (0) | 2018.02.13 |
---|---|
#6. Django와 Apache2 연동하기 in 라즈베리파이3 (0) | 2018.02.13 |
#5. 파일전용 hash 뷰어를 만들어보자 (0) | 2018.02.13 |
#4. 티스토리 이미지 크롤링 (0) | 2017.07.28 |
#2. jpg Carving Tool with Python 2.7.13 (0) | 2017.05.28 |
블로그의 정보
Data+
Qerogram