Ticket #2112: strip_www2.diff

File strip_www2.diff, 1.3 KB (added by pa-ching, 9 years ago)

My mistake! Fixed a little error.

  • django/conf/global_settings.py

    148148# Whether to prepend the "www." subdomain to URLs that don't have it.
    149149PREPEND_WWW = False
     151# Alternatively, whether to strip the "www." subdomain from URLs that have it.
     152STRIP_WWW = False
    151154# List of compiled regular expression objects representing User-Agent strings
    152155# that are not allowed to visit any page, systemwide. Use this for bad
    153156# robots/crawlers. Here are a few examples:
  • django/middleware/common.py

    3535        new_url = old_url[:]
    3636        if settings.PREPEND_WWW and old_url[0] and not old_url[0].startswith('www.'):
    3737            new_url[0] = 'www.' + old_url[0]
     38        elif settings.STRIP_WWW and old_url[0] and old_url[0].startswith('www.'):
     39            new_url[0] = old_url[0][4:]
    3840        # Append a slash if append_slash is set and the URL doesn't have a
    3941        # trailing slash or a file extension.
    4042        if settings.APPEND_SLASH and (old_url[1][-1] != '/') and ('.' not in old_url[1].split('/')[-1]):
Back to Top