Home > Backend Development > PHP Tutorial > How to put static files such as sitemapxml in the django project into the web root directory

How to put static files such as sitemapxml in the django project into the web root directory

WBOY
Release: 2016-07-29 09:02:24
Original
1364 people have browsed it

There are two options

First, add a new urlpattern to

url(r'^sitemap\.xml/$', TemplateView.as_view(template_name='sitemap.xml',
                                            c/xml')),
Copy after login

urls.py and use TemplateView to display it

Second,

Directly hand it over to nginx for processing, and add the static to be processed in the nginx conf file URL and path

location  /sitemap.xml {
    alias  /path/to/static/sitemap.xml;
}
Copy after login

I have not practiced the first solution, but it should be ok. The second solution I used

Reference: http://stackoverflow.com/questions/18424260/django-serving-robots-txt -efficiently

The above introduces how to put static files such as sitemapxml in the web root directory in the Django project, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template