力HTTPS和带WWW没有收到证书错误 [英] Force HTTPS and strip WWW without receiving Cert error
问题描述
我工作的一个网站,只有拥有了domain.com的SSL证书。我想删除了www。并重定向到domain.com。这个我工作的罚款。
我也想迫使HTTPS的所有网页上,这个工作正常,如果WWW。没有打出来。
有错误发生时, https://www.domain.com 我们的网址。
我可以看到它重写 https://domain.com 但我得到一个证书错误,我必须接受或拒绝。
有没有办法解决,而无需购买另一个证书?
下面是两个规则的多种组合我已经尝试了(他们中许多人来自其他等答案)。
的1。
的RewriteCond%{HTTP_HOST} ^(WWW \)(+)[OR]
的RewriteCond%{} HTTPS关闭
的RewriteCond%{HTTP_HOST} ^(WWW \)?(+)
重写规则^ https://开头%2%{REQUEST_URI} [R = 301,L]
2。
的RewriteCond%{} HTTPS = ON
的RewriteCond%{HTTP_HOST} ^ WWW \。(。+)$ [NC]
重写规则^ https://开头%1%{REQUEST_URI} [R = 301,L]
的RewriteCond%{} HTTPS!=上
的RewriteCond%{HTTP_HOST} ^ WWW \。(。+)$ [NC]
重写规则^ HTTP://%1%{REQUEST_URI} [R = 301,L]
的RewriteCond%{} SERVER_PORT!^ 443
重写规则^ HTTPS://domain.com% {REQUEST_URI} [R = 301,L]
我不认为有办法解决。该证书的错误是从SSL(TLS)连接,这恰好任何HTTP请求进行之前来了。
如果用户去 http://www.domain.com/ 或只的 http://domain.com/ 你可以重定向到的 https://domain.com/ 就好了。 如果用户去 https://www.domain.com/ ,他们将接受之前得到一个证书错误一个重定向。
我觉得你的选择是:
- 点www.domain.com到具有HTTPS禁用的服务器。打 https://www.domain.com/ 时,用户会得到一个连接错误,这可能是preferrable到证书错误
- 在购买证书为www.domain.com或* .domain.com
I am working on a site that only owns an SSL cert for domain.com. I am trying to remove the www. and redirect to domain.com. This I have working fine.
I also want to force HTTPS on all pages, this works fine if www. is not typed.
There error occurs when https://www.domain.com us the URL.
I can see it rewrite to https://domain.com but I get a cert error that I have to accept or reject.
Is there a way around this without buying another certificate?
Here are two of the many combinations of rules I have tried (many of them were from other SO answers).
1.
RewriteCond %{HTTP_HOST} ^(www\.)(.+) [OR]
RewriteCond %{HTTPS} off
RewriteCond %{HTTP_HOST} ^(www\.)?(.+)
RewriteRule ^ https://%2%{REQUEST_URI} [R=301,L]
2.
RewriteCond %{HTTPS} =on
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ https://%1%{REQUEST_URI} [R=301,L]
RewriteCond %{HTTPS} !=on
RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
RewriteRule ^ http://%1%{REQUEST_URI} [R=301,L]
RewriteCond %{SERVER_PORT} !^443
RewriteRule ^ https://domain.com%{REQUEST_URI} [R=301,L]
I don't think there's a way around this. The cert error is coming from the SSL (TLS) connection, which happens before any HTTP requests are made.
If the user went to http://www.domain.com/ or just http://domain.com/ you could redirect to https://domain.com/ just fine. If the user went to https://www.domain.com/, they would get a cert error before receiving a redirect.
I think your options are:
- Point www.domain.com to a server that has HTTPS disabled. Users would get a connection error when hitting https://www.domain.com/, which may be preferrable to a cert error
- Buy a cert for www.domain.com or *.domain.com
这篇关于力HTTPS和带WWW没有收到证书错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!