HTTPS重定向到非www和http到www

编程入门 行业动态 更新时间:2024-10-24 22:26:27
本文介绍了HTTPS重定向到非www和http到www的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

访问:

mysite -redirected于─> www.mysite

www.mysite -redirected于─> mysite

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

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

感谢,如果有人能帮助我。

解决方案

从 www.mysite 重定向到 HTTPS ://mysite 只能发生在客户端后,已经取得了初步的要求 www.mysite

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

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

(你也可以使用服务器名称指示与两个不同的证书,如果你希望客户端来支持它,但是这通常是完全不同的主机名。)

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

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 :

mysite -redirected to-> www.mysite

While:

www.mysite -redirected to-> mysite

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 www.mysite to mysite can only happen after the client has made an initial request to www.mysite.

For this initial connection to work, the server at www.mysite must have a certificate valid for www.mysite, 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: mysite and www.mysite; 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 mysite and www.mysite when you apply for one of the other, sometimes without an extra fee.

更多推荐

HTTPS重定向到非www和http到www

本文发布于:2023-07-16 03:50:16,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1117555.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:重定向   HTTPS   http   www

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!