【问题标题】:AWS EC2 WordPress, How Do I force the URL to redirect to HTTPS and force WWWAWS EC2 WordPress,如何强制 URL 重定向到 HTTPS 并强制 WWW
【发布时间】:2018-06-05 09:42:09
【问题描述】:

我在 AWS (Amason Web Services) 服务器上有一个新的 EC2 实例。我需要强制 URL 始终重写(重定向)为 URL 中的 HTTPS 和 www,无论它们来自哪个 URL。

我确定 apache 配置中必须有重写规则,对吧?

【问题讨论】:

    标签: apache amazon-web-services web-config config


    【解决方案1】:

    找到答案,您需要将其写入 Apache.conf 配置文件

    RewriteEngine On
    RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
    RewriteCond %{HTTP:X-Forwarded-Proto} !https [OR]
    RewriteCond %{HTTP_HOST} !^www [NC]
    RewriteRule ^(.*)$ https://www\.%1/$1 [L,R=301]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-09-27
      • 1970-01-01
      • 2018-08-20
      • 2017-03-30
      • 1970-01-01
      • 1970-01-01
      • 2016-09-05
      • 2018-10-27
      相关资源
      最近更新 更多