Instead of showing an error, redirect the user back to the correct URL.
These should never be linked, but can show up if you navigate via a 404
page, as shown by Jonathan Katz.
@cache(hours=8)
def mbox(request, listname, mboxname):
return HttpResponse('This needs to be handled by the webserver. This view should never be called.', content_type='text/plain')
+
+# Redirect to the requested url, with a slash first. This is used to remove
+# trailing slashes on messageid links by doing a permanent redirect. This is
+# better than just eating them, since this way we only end up with one copy
+# in the cache.
+@cache(hours=8)
+def slash_redirect(request, url):
+ print url
+ return HttpResponsePermanentRedirect("/%s" % url)
(r'^message-id/raw/([^/]+)$', 'archives.mailarchives.views.message_raw'),
(r'^archives-search/', 'archives.mailarchives.views.search'),
+ # message-id with a slash needs to be redirected to one without it
+ (r'^(message-id/.*)/$', 'archives.mailarchives.views.slash_redirect'),
+
# Date etc indexes
(r'^list/([\w-]+)/$', 'archives.mailarchives.views.monthlist'),
(r'^list/([\w-]+)/(\d+)-(\d+)/$', 'archives.mailarchives.views.datelist'),