Changeset 1548
- Timestamp:
- 12/05/05 09:25:55 (3 years ago)
- Files:
-
- django/trunk/django/middleware/common.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/django/middleware/common.py
r1166 r1548 31 31 32 32 # Check for a redirect based on settings.APPEND_SLASH and settings.PREPEND_WWW 33 old_url = [request.META ['HTTP_HOST'], request.path]33 old_url = [request.META.get('HTTP_HOST', ''), request.path] 34 34 new_url = old_url[:] 35 if settings.PREPEND_WWW and not old_url[0].startswith('www.'):35 if settings.PREPEND_WWW and old_url[0] and not old_url[0].startswith('www.'): 36 36 new_url[0] = 'www.' + old_url[0] 37 37 # Append a slash if append_slash is set and the URL doesn't have a … … 41 41 if new_url != old_url: 42 42 # Redirect 43 newurl = "%s://%s%s" % (os.environ.get('HTTPS') == 'on' and 'https' or 'http', new_url[0], new_url[1]) 43 if new_url[0]: 44 newurl = "%s://%s%s" % (os.environ.get('HTTPS') == 'on' and 'https' or 'http', new_url[0], new_url[1]) 45 else: 46 newurl = new_url[1] 44 47 if request.GET: 45 48 newurl += '?' + request.GET.urlencode()
