gpt4 book ai didi

apache - 将所有流量重定向到 https ://www. 目前我有两个版本 http://www 和 https://www

转载 作者:太空宇宙 更新时间:2023-11-03 14:06:25 26 4
gpt4 key购买 nike

我有一个全新的网站,最初是 http://然后我将网站重定向到 http://www它的工作就像一个魅力,但自从我安装了 SSL 我有两个版本的网站 http://www.example.comhttps://www.example.com .我在 .htaccess 中尝试了几个命令,但我仍然有两个版本,有人可以帮我解决这个问题,下面是我在 .htaccess 中使用的代码:

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule .* https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

最佳答案

首先 www 和 https 之后:

RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ https://www.%{HTTP_HOST}%{REQUEST_URI} [NE,L,R=301]
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [NE,L,R=301]

关于apache - 将所有流量重定向到 https ://www. 目前我有两个版本 http://www 和 https://www,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40693264/

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