【问题标题】:Redirecting http to https将 http 重定向到 https
【发布时间】:2015-06-17 21:23:27
【问题描述】:

我想将我的所有 http 流量重定向到 https,目前在我的 htaccess 文件中我有以下重定向我的 http 流量:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
</IfModule>

这会将我所有的非 www 重定向到 www。确保覆盖我的所有基础的最佳方法是什么,这意味着重定向以下所有内容:

http://example.com to https://www.example.com
https://example.com to https://www.example.com
http://www.example.com to https://www.example.com

【问题讨论】:

    标签: apache .htaccess redirect ssl https


    【解决方案1】:

    您可以在 .htaccess 文件中使用它。只需将example.com 替换为您的域,所有基础都应涵盖。

    IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{HTTP_HOST} !^www\. [NC,OR]
    RewriteCond %{HTTPS} !^on
    RewriteRule ^(.*)$ https://www.example.com/$1 [R=301,L]
    </IfModule>
    

    【讨论】:

      猜你喜欢
      • 2017-11-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-24
      • 2013-11-05
      • 2012-11-02
      • 2011-03-29
      • 2018-02-02
      相关资源
      最近更新 更多