@@ -10,12 +10,17 @@ class ForceCanonicalHostnameMiddleware(object):
* Performs redirects to strip trailing "index.html"
* performs redirects based on APPEND_SLASH
* performs redirects based on site-specific REDIRECT_TABLE
* adds cache headers to provide hints to squid
"""
# Never allow connection to the /admin part of the site without SSL
if (not request.is_secure) and request.path.startswith('/admin'):
url = 'https://sfconservancy.org%s' % request.path
return http.HttpResponseRedirect(url)
# Check for a redirect based on settings.APPEND_SLASH
host = http.get_host(request)
old_url = [host, request.path]
new_url = old_url[:]
# Append a slash if append_slash is set and the URL doesn't have a
# trailing slash or a file extension.