【问题标题】:Redirect non HTTPS to HTTPS将非 HTTPS 重定向到 HTTPS
【发布时间】:2017-04-02 08:52:01
【问题描述】:

我正在尝试强制非 HTTPS 访问者使用 HTTPS,请参阅下面的代码

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]

RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{SERVER_NAME}/%$1 [R,L]

它将 example.com 重定向到 https://example.com/index.php 我只想将 example.com 重定向到 https://example.com

请帮忙。

【问题讨论】:

  • 你可以试试这个:RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://%{SERVER_NAME}/%$1 [R,L]

标签: .htaccess mod-rewrite


【解决方案1】:

颠倒顺序:

RewriteEngine On

RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{SERVER_NAME}/$1 [R,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-04-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-04-06
    • 1970-01-01
    相关资源
    最近更新 更多