当 SSL 证书为非 www 时,在 https www 上将 www 重写为非 www 失败
Rewrite www to non-www fails on https www when SSL Cert is non-www
我尝试先将 http 和 https 的 www 重写为非 www。
适用于 http 请求,但对于 https 请求,浏览器在 www 存在时显示 'connection is not private'。
我的 SSL 证书分配给了非 www.我想知道是否有办法将 https www 重定向到非 www ?到目前为止,我已经尝试了不同的例子但没有成功:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/ [R=301,L]
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/ [R=301,L]
浏览器中显示如下错误信息(当https://www.example.com
):
Your connection is not private
This server could not prove that it is www.example.com
; its security
certificate is from foobar.com. This may be caused by a
misconfiguration or an attacker intercepting your connection.
到目前为止,我认为这是不可能的,除非我有 www.example.com
的 SSL 证书,否则连接永远不会发生,服务器也不会发送重定向响应。
So far I think it's not possible unless I have the SSL certificate for www.foobar.com otherwise the connection will never happen and the server won't send a redirection response.
完全正确。
浏览器将尝试建立到服务器的 HTTPS 连接,但由于提供的证书对域名无效,它将中断连接。
所以在这种情况下,您甚至没有达到可以重写请求的地步。
如果您希望它在用户的浏览器中运行,您将需要获得包含域名的 www 和非 www 版本的证书。
我尝试先将 http 和 https 的 www 重写为非 www。 适用于 http 请求,但对于 https 请求,浏览器在 www 存在时显示 'connection is not private'。
我的 SSL 证书分配给了非 www.我想知道是否有办法将 https www 重定向到非 www ?到目前为止,我已经尝试了不同的例子但没有成功:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ http://%1/ [R=301,L]
RewriteCond %{HTTPS} on
RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
RewriteRule ^(.*)$ https://%1/ [R=301,L]
浏览器中显示如下错误信息(当https://www.example.com
):
Your connection is not private
This server could not prove that it is
www.example.com
; its security certificate is from foobar.com. This may be caused by a misconfiguration or an attacker intercepting your connection.
到目前为止,我认为这是不可能的,除非我有 www.example.com
的 SSL 证书,否则连接永远不会发生,服务器也不会发送重定向响应。
So far I think it's not possible unless I have the SSL certificate for www.foobar.com otherwise the connection will never happen and the server won't send a redirection response.
完全正确。
浏览器将尝试建立到服务器的 HTTPS 连接,但由于提供的证书对域名无效,它将中断连接。
所以在这种情况下,您甚至没有达到可以重写请求的地步。
如果您希望它在用户的浏览器中运行,您将需要获得包含域名的 www 和非 www 版本的证书。