【问题标题】:Cloudflare redirect to https://wwwCloudflare 重定向到 https://www
【发布时间】:2020-05-27 22:40:45
【问题描述】:

我在 Cloudflare 中的 Flexible 选项上启用了 SSL,并将 Automatic HTTPS rewrites 设置为 ON。

我想要以下:

example.com

www.example.com

http://example.com

http://www.example.com

将它们全部重定向到

https://www.example.com

我必须在 cloudflare 网站中添加哪些重定向规则? 我尝试在 .htaccess 中编写规则,但没有成功。

【问题讨论】:

    标签: apache https cloudflare


    【解决方案1】:
    RewriteEngine On
    RewriteCond %{HTTP_HOST} !^www\. [NC]
    RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    RewriteCond %{HTTP:X-Forwarded-Proto} !https
    RewriteCond %{HTTPS} off
    RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-05-22
      • 1970-01-01
      • 2012-06-09
      • 2017-08-02
      • 2019-01-31
      • 2016-09-24
      • 1970-01-01
      相关资源
      最近更新 更多