.htaccess 将通配符子域的 https://www 重定向到非 www

.htaccess redirect https://www to non www for wildcard subdomains

我正在使用 htaccess 为所有子域强制使用 https 并删除 www。除了有人手动添加 https://www. - then we get a security error. How can I force https://www 之外,这是有效的。使用非 www url?

RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1%{REQUEST_URI} [R=301,QSA,NC,L]
RewriteCond %{HTTPS_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1%{REQUEST_URI} [R=301,QSA,NC,L]
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

'problem' 是证书而不是重定向。

根据 PLESK 支持 https://support.plesk.com/hc/en-us/articles/115000067665-Wildcard-SSL-on-a-subdomain-is-not-working-with-www-prefix