Codeigniter语言 - http 到 https 中的 .htaccess 重定向问题



当我尝试使用或不使用 www(example.com、www.example.com(重定向以 https://www.example.com 时,我收到"页面未正确重定向"错误消息。

RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.example.com$
RewriteRule ^(.*)$ "https://example.com/$1" [R=301,L]

我也绑在下面的代码

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://www.example.com%{REQUEST_URI}

但是当我尝试在没有 www To https://www.example.com 的情况下重定向时,工作正常。

我需要重定向有或没有 www example.com To https://www.example.com

下面的代码正在重定向(有或没有www(.example.com到 https://www.example.com

RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?(example.com)$
RewriteCond %{HTTP:X-Forwarded-Proto} !https [NC]
RewriteCond %{HTTPS} off
RewriteRule (.*) https://www.example.com/$1 [R=302,L]

最新更新