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
WBOYOriginal
2016-07-29 09:02:241376browse

There are two options

First, add a new urlpattern to

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

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;
}

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.

Statement:
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