IIS 7.5 - 使用www发布的证书强制规范和https

时间:2016-02-25 23:25:02

标签: iis web https canonical-link

我们为其中一个域购买了SSL证书。证书颁发给www.ourdomain.com。我很难编写web.config重写规则来强制使用www和https。问题是证书本身。同样,证书颁发给我们域名的www变体。因此,只有在URL中存在www时才有效。目前,我使用以下规则:

<rule name="Redirect to WWW" stopProcessing="true" >'
    <match url="(.*)" />
    <conditions>
        <add input="{HTTP_HOST}" pattern="^www\." negate="true"/>
    </conditions>
    <action type="Redirect" url="https://www.{HTTP_HOST}{HTTP_URL}" redirectType="Permanent" appendQueryString="false" />
</rule>
<rule name="Redirect to HTTPS">
    <match url="(.*)" />
    <conditions>
        <add input="{HTTPS}" pattern="OFF"/>
    </conditions>
    <action type="Redirect" url="https://{HTTP_HOST}{HTTP_URL}" redirectType="Permanent" appendQueryString="false" />
</rule>

http ourdomain.com没关系。 http www.ourdomain.com是好的。 https www.ourdomain.com没问题。 https ourdomain.com FAILS出现浏览器错误

我认为它失败了,因为IIS在获取web.config中的这些规则之前会处理SSL。并且因为证书要求请求www,所以用户浏览器会出错。在错误页面上,您可以单击“仍然继续”,并启动web.config规则并强制重定向。这可以修复,还是我需要在域中购买没有www的新证书?我在域中没有www的服务器上安装的其他证书适用于所有4个URL示例。

更新:仍在寻找反馈

0 个答案:

没有答案