我在.htaccess中使用此代码
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ https://www.%{HTTP_HOST}%{REQUEST_URI}$1 [R=301,L]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI}$1
将所有请求重定向到https,例如 example.com 会重定向到 https://www.example.com 但我的问题是,当网址如下示例时.com / hello 或 http://www.example.com/hello 它重定向但是 https 但是会导致404错误,即使它重新定向到网址也是如此将example.com或example.com/hello添加到https://www.example.com或https://www.example.com/hello,没有404错误。