This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class RemoveWWW(object): | |
def process_request( self, request ): | |
try: | |
if request.META['HTTP_HOST'].lower().find('www.') == 0: | |
from django.http import HttpResponsePermanentRedirect | |
return HttpResponsePermanentRedirect( request.build_absolute_uri().replace('//www.', '//') ) | |
except: | |
pass | |
return None |