Heroku Django: Redirect all requests for www. to root domain
Question: I need to redirect all requests coming from `www.mysite.com` to `mysite.com`

I have found the [solution in
rails](http://blog.dynamic50.com/2011/02/22/redirect-all-requests-for-www-to-
root-domain-with-heroku/), but how can I do that in django/python?

The only solution I could fine, which was posted by a moderator on GoDaddy was
the above. Seems like I cannot resolve this kind of problem through the DNS
Manager of GoDaddy.

Any hints or thoughts?

Thanks in advance.


Answer: Solved whit this:

    
    
    from django.http import HttpResponsePermanentRedirect
    
    class WWWRedirectMiddleware(object):
        def process_request(self, request):
            if request.META['HTTP_HOST'].startswith('www.'):
                return HttpResponsePermanentRedirect('http://mysite.com')
    

