简体   繁体   English

Django 重定向 http -> https

[英]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.

相关问题 在AWS-ELB-Tornado上将HTTP重定向到HTTPS - Redirecting HTTP to HTTPS on AWS-ELB-Tornado Vagrant-Django服务器-为什么主机重定向到https? - Vagrant - Django server - Why is host redirecting to https? Python3 + Nginx:在AWS Elastic Beanstalk上将HTTP流量重定向到HTTPS - Python3 + Nginx: Redirecting HTTP traffic to HTTPS on AWS Elastic Beanstalk Cherrypy应用程序重定向到http而不是nginx后面的https - Cherrypy application redirecting to http instead of https behind nginx Django - 重定向回页面显示 http 响应(Json 数据)而不呈现 - Django - redirecting back to a page shows http response (Json data) and not rendering 有没有办法在Django中重定向之前修改HTTP_REFERRER? - Is there a way to modify the HTTP_REFERRER before redirecting in Django? 使用nginx将http重定向到https而不是使用django-sslify? - Redirect http to https with nginx instead of using django-sslify? 使用 Django 在 Google App Engine Flexible 上永久重定向 http 到 https - Permanently Redirect http to https on Google App Engine Flexible with Django Django-社交身份验证(请求URL显示的是http而不是https) - Django - Social Auth (Request URL is showing http instead of https) 如何使用 Django Nginx 应用程序与 HTTP 和 Z0E8433F9A404F26F3BA601C14B1 请求? - How to use Django Nginx Application with both HTTP and HTTPS requests?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM