[英]Django redirecting http -> https
I am running:我在跑步:
python manage.py runserver localhost:44100
And this is redirecting me to https
:这将我重定向到
https
:
» http http://localhost:44100/
HTTP/1.0 301 Moved Permanently
Content-Type: text/html; charset=utf-8
Date: Mon, 05 Mar 2018 14:09:09 GMT
Location: https://localhost:44100/
Server: WSGIServer/0.1 Python/2.7.14
X-Frame-Options: SAMEORIGIN
Why / how is this happening?为什么/这是如何发生的? What setting does control whether
Django
accepts http
/ https
?什么设置控制
Django
是否接受http
/ https
?
The runserver
command only handles http. runserver
命令只处理http。
However if you have SECURE_SSL_REDIRECT
set to True
then you will be redirected from http to https. 但是,如果您将
SECURE_SSL_REDIRECT
设置为True
那么您将从http重定向到https。
See the Django docs on SSL/HTTPS for more information. 有关更多信息,请参阅SSL / HTTPS上的Django文档。
My best guess is that in the settings.py file of your project you have set 我最好的猜测是你已经设置的项目的settings.py文件
SECURE_SSL_REDIRECT = True
which causes your http to redirect to https. 这会导致您的http重定向到https。 You can read about it here .
你可以在这里阅读它。
If that is the case, you might want to remove that line and clear your browser cache before it starts to work as intended. 如果是这种情况,您可能希望删除该行并清除浏览器缓存,然后才能按预期工作。
Hope that helps. 希望有所帮助。
Use python manage.py runssslserver
to handle SSL and https.使用
python manage.py runssslserver
来处理 SSL 和 https。 You have to install django-sslserver
first and set it in您必须先安装
django-sslserver
并将其设置在
INSTALLED_APPS = [
'sslserver',
]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.