I have uploaded robots.txt into my templates directory on my production server. I am using generic views;
from django.views.generic import TemplateView
(r'^robots\.txt$', TemplateView.as_view(template_name='robots.txt', content_type='text/plain')),
However, when I load robots.txt on the browser I get a 404 - Page not found.
Can someone suggest what needs to be done to fix this. Thanks.
I should point out that on the local environment this seems to be working.
Finally got it. I had to add a '/' in ^robots.txt$
(r'^robots\.txt/$', TemplateView.as_view(template_name='robots.txt', content_type='text/plain')),
That's elementary! I presumed that by default APPEND_SLASH it True however, on the production server it didn't work.
Let me know if anyone can provide some insights on it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With