title: Django – remove the trailing slash from 'sitemap.xml/'
body: <p>I am using Django's sitemap framework and have a sitemap index. My urls file looks like this:</p>
  <pre><code>urls = [
      path('', include('movies.urls')),
      path('', include('accounts.urls')),
      ...
      path('admin/', admin.site.urls),
  ]
  
  urlpatterns = i18n_patterns(*urls, prefix_default_language=True,)
  
  sitemaps = {
      'main': MainSitemap,
      'movies': MoviesSitemap,
  }
  
  urlpatterns.extend([
      path('sitemap.xml', views.index, {'sitemaps': sitemaps}),
      path('sitemap-&lt;section&gt;.xml', views.sitemap, {'sitemaps': sitemaps},
       name='django.contrib.sitemaps.views.sitemap'),
  ])
  </code></pre>
  <p>This is implemented in accordance with the recommendations in the <a href="https://docs.djangoproject.com/en/3.2/ref/contrib/sitemaps/" rel="nofollow noreferrer">documentation of Django</a>.</p>
  <p>The problem is that I always get 404 when trying to access my sitemap index: <em>example.com/sitemap.xml</em>. This occurs because a redirect occurs automatically to the non-existent <em>example.com/sitemap.xml/</em> URL with a trailing slash.</p>
  <p>How can I avoid a slash being appended to the .xml sitemap file? I have tried using re_path but to no avail.</p>