您好,欢迎访问一九零五行业门户网

django项目中如何把sitemapxml等静态文件放到web根目录

有两种方案
一、
url(r'^sitemap\.xml/$', templateview.as_view(template_name='sitemap.xml', c/xml')),
urls.py中加入新的urlpattern,用templateview去展示二、
 直接交给nginx来处理,在nginx的conf文件中加入要处理的static url和路径
location /sitemap.xml { alias /path/to/static/sitemap.xml;}
第一种方案我没实践,应该也是ok的,我用的第二种方案参考:http://stackoverflow.com/questions/18424260/django-serving-robots-txt-efficiently
以上就介绍了django项目中如何把sitemapxml等静态文件放到web根目录,包括了方面的内容,希望对php教程有兴趣的朋友有所帮助。
其它类似信息

推荐信息