IIS URL重写 - 如何防止IIS在URL重写部分中接受子域通配符前缀xyz.domain.com

时间:2016-03-02 18:10:22

标签: c# .net ssl iis url-rewriting

我提供的规则可以将我们的网站流量从非wwww / http重定向到www / https路径。我已经输入了以下规则:

<rule name="Redirect to www" enabled="true" patternSyntax="ECMAScript" stopProcessing="true">
                <match url="(.*)" />
                <conditions>
                    <add input="{HTTP_HOST}" pattern="^myway.com" />
                </conditions>
                <action type="Redirect" url="https://www.myway.com/{R:0}" />
            </rule>
            <rule name="All to https" enabled="true" stopProcessing="true">
                <match url="(.*)" />
                <conditions>
                    <add input="{HTTPS}" pattern="^OFF$" />
                </conditions>
                <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" />
            </rule>

它适用于所有网络流量,但它也接受域名中的通配符文字,例如输入ww.domain.com,myname.domain.com也将通向该网站,这将通过浏览器提供SSL证书警告提示。

enter image description here

我是否需要添加/编辑规则?

1 个答案:

答案 0 :(得分:0)

由于domain.com与www.domain.com不匹配,因此不会进行SSL连接。并且因为HTTP重定向只能在建立SSL连接后才能完成,所以它将无法进行重定向。您唯一的机会是获得包含domain.com和www.domain.com的证书。