有两种方案
一、
url(r'^sitemap\.xml/$', TemplateView.as_view(template_name='sitemap.xml',
c/xml')),二、
直接交给nginx来处理,在nginx的conf文件中加入要处理的static URL和路径
location /sitemap.xml {
alias /path/to/static/sitemap.xml;
}参考:http://stackoverflow.com/questions/18424260/django-serving-robots-txt-efficiently
以上就介绍了django项目中如何把sitemapxml等静态文件放到web根目录,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号