[英]Redirect from HTTP to HTTPS in Python Django
I want to redirect the python
and django
websites from http
to https
. 我想将
python
和django
网站从http
重定向到https
。 When I'm using the SECURE_SSL_REDIRECT = True
in settings.py
, I'm getting the folder structure: 当我在
settings.py
使用SECURE_SSL_REDIRECT = True
时,我得到了文件夹结构:
Are you using apache? 你在使用apache吗?
Try this on your .htacess inside www folder. 在.htacess里面的www文件夹中试试这个。
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.yourdomain.com/$1 [R,L]
supposing that: 假设:
apache2
; apache2
; default-ssl.conf
file which, if you are using a debian-like
distro, is located in the directory /etc/apache2/sites-available
; default-ssl.conf
文件开始的,如果你使用类似debian-like
发行版,它位于/etc/apache2/sites-available
; mod_wsgi
, having modified your default-ssl.conf
as described in this howto mod_wsgi
的,具有修饰您的default-ssl.conf
在描述这个HOWTO you could try defining a permanent redirect to https in the <VirtualHost *:80>
directive, always in your default-ssl.conf
, as shown below: 您可以尝试在
<VirtualHost *:80>
指令中定义永久重定向到https,始终在default-ssl.conf
,如下所示:
<IfModule mod_ssl.c>
<VirtualHost *:80>
ServerName your-server.name
Redirect permanent / https://your-server.name
</VirtualHost>
<VirtualHost _default_:443>
ServerName your-server.name
...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.