【问题标题】:.htaccess - redirect from www https to non www https.htaccess - 从 www https 重定向到非 www https
【发布时间】:2016-06-05 13:38:03
【问题描述】:

我有 .htaccess:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
RewriteCond %{HTTP_HOST} ^www\.(.+) [NC]
RewriteRule ^(.*) http://%1 [R=302,NE,L]

当我从(示例)重定向时它工作正常: 从 http:// 重定向到正确的 https:// 来自http://www 被重定向到正确的 https:// 但是当我有https://www。我没有重定向和“不受信任的连接”。

我应该在我的 htaccess 文件中更改什么?

【问题讨论】:

    标签: apache .htaccess redirect


    【解决方案1】:

    也只需根据您的第二条规则重定向到 https,例如

    RewriteCond %{HTTP_HOST} ^www\.(.+) [NC]
    RewriteRule ^ https://%1%{REQUEST_URI} [R=302,NE,L]
    

    不相关,但不需要捕获路径,只用REQUEST_URI即可。

    【讨论】:

      猜你喜欢
      • 2014-07-26
      • 2019-12-04
      • 1970-01-01
      • 2013-07-01
      • 2017-05-03
      • 2018-11-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多