-
-
Save bootandy/6563355 to your computer and use it in GitHub Desktop.
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment