您的位置:首页 > 编程语言 > Go语言

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

2016-02-23 10:17 489 查看
有两种方案

一、

url(r'^sitemap\.xml/$', TemplateView.as_view(template_name='sitemap.xml',
content_type='text/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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: