我需要将所有来自 www.mysite 的请求重定向到 mysite
我发现在rails中的解决方案,但我怎么能在django / python中做到这一点?
唯一的解决方案我可以罚款,这是主持人在GoDaddy上发布的是上述内容。似乎我无法通过GoDaddy的DNS管理器解决这类问题。
任何提示或想法?
提前致谢。
解决方案解决这个问题: <$ p $ (自我,请求):如果request.META [', $ d $ if b $ process $ HTTP_HOST']。startswith('www。'): return HttpResponsePermanentRedirect('mysite')
I need to redirect all requests coming from www.mysite to mysite
I have found the solution in rails, 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.
解决方案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('mysite')
更多推荐
Heroku Django:重定向所有www请求。到根域
发布评论