gpt4 book ai didi

apache - 使用负载均衡器重定向 AWS Elastic Beanstalk 上的所有 www 和 http ==>> 非 www https

转载 作者:行者123 更新时间:2023-12-02 08:54:18 25 4
gpt4 key购买 nike

我目前已将所有 http 流量重定向到 https

RewriteEngine On
RewriteCond %{HTTP:X-Forwarded-Proto} !=https
RewriteRule ^/(.*)$ https://%{SERVER_NAME}/$1 [R=301,L]

以上工作正常。

现在我正在尝试添加重写条件,以强制所有 https://www 流量到 https,而不带 www

请注意,这是在弹性负载均衡器后面运行 Apache 的 AWS Elastic Beanstalk

==============================

编辑:

工作代码:

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

最佳答案

试试这个规则:

RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^www\. [NC]
RewriteCond %{SERVER_NAME} ^(www\.)?(.*)$ [NC]
RewriteRule ^/?(.*)$ https://%2/$1 [L,R=301]

关于apache - 使用负载均衡器重定向 AWS Elastic Beanstalk 上的所有 www 和 http ==>> 非 www https,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23411833/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com