From a78e69d4a0acb42fac1a39b3851ba3dbf14a6448 Mon Sep 17 00:00:00 2001 From: Kasper Brandt Date: Thu, 24 Mar 2016 15:40:55 +0100 Subject: [PATCH] [#273] Add robots.txt for live and dev environments --- akvo/templates/robots/dev-robots.txt | 2 ++ akvo/templates/robots/live-robots.txt | 2 ++ akvo/urls.py | 15 +++++++++++++++ 3 files changed, 19 insertions(+) create mode 100644 akvo/templates/robots/dev-robots.txt create mode 100644 akvo/templates/robots/live-robots.txt diff --git a/akvo/templates/robots/dev-robots.txt b/akvo/templates/robots/dev-robots.txt new file mode 100644 index 0000000000..77470cb39f --- /dev/null +++ b/akvo/templates/robots/dev-robots.txt @@ -0,0 +1,2 @@ +User-agent: * +Disallow: / \ No newline at end of file diff --git a/akvo/templates/robots/live-robots.txt b/akvo/templates/robots/live-robots.txt new file mode 100644 index 0000000000..14267e9032 --- /dev/null +++ b/akvo/templates/robots/live-robots.txt @@ -0,0 +1,2 @@ +User-agent: * +Allow: / \ No newline at end of file diff --git a/akvo/urls.py b/akvo/urls.py index bbddcd31de..bcf8e6f4e1 100644 --- a/akvo/urls.py +++ b/akvo/urls.py @@ -263,3 +263,18 @@ if settings.REQUIRED_AUTH_GROUPS: check_auth_groups(settings.REQUIRED_AUTH_GROUPS) + + +# Robots.txt +if settings.DEBUG: + urlpatterns += patterns( + '', + url(r'^robots\.txt$', + TemplateView.as_view(template_name='robots/dev-robots.txt', content_type='text/plain')) + ) +else: + urlpatterns += patterns( + '', + url(r'^robots\.txt$', + TemplateView.as_view(template_name='robots/live-robots.txt', content_type='text/plain')) + )