【问题标题】:HTTP to HTTPS using .fcgi and .htaccess in django在 django 中使用 .fcgi 和 .htaccess 的 HTTP 到 HTTPS
【发布时间】:2016-09-10 22:18:30
【问题描述】:

我有 mysite.fcgi 文件,其中写入了 django 项目的位置。我有工作的 .htaccess 文件。

AddHandler fcgid-script .fcgi
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ mysite.fcgi/$1 [QSA,L]

我想让这个 .htaccess 将所有 http 请求重定向到 https。我试图将 https:// 放在 mysite.fcgi 的前面,但没有用。非常感谢任何帮助。

【问题讨论】:

    标签: django apache .htaccess fastcgi


    【解决方案1】:

    您可以将以下行添加到您的 .htaccess 文件中:

    RewriteCond %{HTTPS} !=on
    RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    

    另请参阅this page 了解更详细的讨论和其他方法。

    【讨论】:

    • 谢谢!该链接非常有用。
    猜你喜欢
    • 2012-01-10
    • 2016-01-20
    • 2015-02-16
    • 2016-03-10
    • 1970-01-01
    • 1970-01-01
    • 2010-12-21
    • 2016-08-31
    • 1970-01-01
    相关资源
    最近更新 更多