使用测试服务器http://127.0.0.1:8000/en/sitemap.xml
正确地在Firefox中返回XML站点地图但在Chrome中我得到了404.为什么会这样?
所有其他网页的网址在Chrome中路线确定,但这是我获得的网站地图:
Using the URLconf defined in mycms.urls, Django tried these URL patterns, in this order:
^media/(?P<path>.*)$
^static\/(?P<path>.*)$
^en/ ^admin/
^en/ ^sitemap\.xml$
^en/ ^select2/
^en/ ^ ^cms_wizard/
^en/ ^ ^(?P<slug>[0-9A-Za-z-_.//]+)/$ [name='pages-details-by-slug']
^en/ ^ ^$ [name='pages-root']
^en/ ^ ^forms/submit/$ [name='djangocms_forms_submissions']
The current URL, /en/sitemap.xml/, didn't match any of these.
我的urls.py
是
admin.autodiscover()
urlpatterns = i18n_patterns('',
url(r'^admin/', include(admin.site.urls)), # NOQA
url(r'^sitemap\.xml$', 'django.contrib.sitemaps.views.sitemap',
{'sitemaps': {'cmspages': CMSSitemap}}),
url(r'^select2/', include('django_select2.urls')),
# url(r'^polls/', include('polls.urls', namespace='polls')),
url(r'^', include('cms.urls')),
url(r'^', include('djangocms_forms.urls')),
)
# This is only needed when using runserver.
if settings.DEBUG:
urlpatterns = patterns('',
url(r'^media/(?P<path>.*)$', 'django.views.static.serve', # NOQA
{'document_root': settings.MEDIA_ROOT, 'show_indexes': True}),
) + staticfiles_urlpatterns() + urlpatterns # NOQA
Safari试图对其进行格式化,但似乎可以获得站点地图。它在Firefox中看起来很好:
<urlset>
<url>
<loc>http://example.com/en/</loc>
<lastmod>2016-11-22</lastmod>
<changefreq>monthly</changefreq>
<priority>0.5</priority>
</url>
<url>
<loc>http://example.com/en/aboutus/</loc>
<lastmod>2016-11-22</lastmod>
<changefreq>monthly</changefreq>
<priority>0.5</priority>
</url>
<url>
...
</urlset>
答案 0 :(得分:1)
我无法相信我花了很多时间没有注意到最终的/
是导致问题的原因。
我将这篇文章留在这里以防万一其他人节省了一些时间......
答案 1 :(得分:1)
对于那些仍然想知道那些&#34; /&#34;意味着只需更新网址
来自 的
以强> url(r'^sitemap\.xml$', 'django.contrib.sitemaps.views.sitemap',
{'sitemaps': {'cmspages': CMSSitemap}}),
url(r'^sitemap\.xml/$', 'django.contrib.sitemaps.views.sitemap',
{'sitemaps': {'cmspages': CMSSitemap}}),