Answer the question
In order to leave comments, you need to log in
How to remove django robots.txt redirect?
You need to remove the redirect from /robots.txt
to /robots.txt/
I read in the documentation about the decorator no_append_slash , but for some reason this does not work:
@no_append_slash
def robots(request, *args, **kwargs):
return HttpResponse(
site_settings.robots_txt,
content_type='text/plain')
urlpatterns = [
path('robots.txt/', views.robots, name='robots'),
path('sitemap.xml/', sitemap, {'sitemaps': views.sitemaps}, name='django.contrib.sitemaps.views.sitemap'),
]
re_path
re_path(r'^testlink$', views.robots, name='robots'),
re_path(r'^robots\.txt$', views.robots, name='robots'),
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question