我有以下的htaccess代码:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond !{HTTPS} off
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
</IfModule>
我希望我的网站在使用HTTPS的情况下重定向到https://www.
,并强制使用www.
子域名,
但当我访问http://www.
(未使用HTTPS)时,它不会将我重定向到https://www
。
RewriteCond %{HTTPS} =off
。 - Michael Berkowskihttps
和www
” https://helponnet.com/2021/03/23/http-to-https-and-enforce-www-in-one-301-redirect-on-htaccess/ - Amit Verma