HTTPS重定向到非www和http到www [英] Redirect https to non-www and http to www



我搜查,发现数百个相关案件,但没有完全按照我的需要。 我需要重定向的组合,请执行以下操作:

访问: -redirected于─> -redirected于─>

对于普通的 HTTP 网站,我想迫使 WWW

但SSL证书只能加www,所以 HTTPS 应的不可以有WWW。


解决方案 重定向到 HTTPS :// 只能发生在客户端后,已经取得了初步的要求

有关此初始连接到工作中,服务器 必须具有有效的 www.mysite证书.COM ,否则,这种连接甚至不会发生(和服务器将不发送重定向响应)。

如果你仍然想重定向,在同一台服务器上,服务器必须present的证书有效期为要服务的主机名。你应该得到两个主题备用名称的DNS条目的证书: ;这将允许您使用相同的证书,同时服务于主机(然后如果需要使用重写规则)。


这是相当普遍的CA颁发证书的有效期为两个 。

I searched and found hundreds of related cases, but none exactly as what I need. I need a combination of redirects to do the following:

Access to : -redirected to->

While: -redirected to->

For normal http site, I want to force www.

But the ssl certificate only works without www, so https should not have the www.

Thanks if anyone can help me.


The redirection from to can only happen after the client has made an initial request to

For this initial connection to work, the server at must have a certificate valid for, otherwise, this connection won't even happen (and the server won't send a redirection response).

If you still want a redirection, on the same server, your server must present a certificate that is valid for the host names you want to serve. You should get a certificate with two Subject Alternative Name DNS entries: and; this will allow you to serve both hosts with the same certificate (and then use the rewrite rules if needed).

(You could also use Server Name Indication with two distinct certificates, if you expect the clients to support it, but that's usually for completely different host names.)

It's quite common for CAs to issue certificates that are valid for both and when you apply for one of the other, sometimes without an extra fee.


登录 关闭
发送“验证码”获取 | 15天全站免登陆