[英]Redirect from HTTP to HTTPS in Python Django
我想將python
和django
網站從http
重定向到https
。 當我在settings.py
使用SECURE_SSL_REDIRECT = True
時,我得到了文件夾結構:
你在使用apache嗎?
在.htacess里面的www文件夾中試試這個。
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.yourdomain.com/$1 [R,L]
假設:
apache2
; default-ssl.conf
文件開始的,如果你使用類似debian-like
發行版,它位於/etc/apache2/sites-available
; mod_wsgi
的,具有修飾您的default-ssl.conf
在描述這個HOWTO 您可以嘗試在<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.