我正在将 ssl 添加到 django 应用程序中,并且我的链接从 https 重定向到 http 时遇到了一些问题。
最终我会让 nginx 将所有 http 请求重定向到 https,但现在我允许两者。
所以如果你去https://www.mysite.com一切都很好。但是,单击“关于链接”: href='/about' 会将您重定向到http://www.mysite.com/about。
About 是一个超级基本(静态)页面。这是 urls.py 中的条目:
(r'^about/$', 'search.views.about'),
这是视图功能:
def about(request):
return render_to_response('search/about.html')
django 不应该将我的用户定向到https://www.mysite.com/about/吗?我相信这与 request.is_secure() 方法有关。对我来说总是返回错误。我已经读到我需要设置 os.environ['HTTPS'] = "on" 以使其返回 true。我该怎么做呢?还有什么我需要做的吗?我应该将 https 硬编码到我的所有链接中吗?
感谢所有的帮助。