简体   繁体   中英

IIS Url Rewrite - How to prevent IIS accepting subdomain wildcard prefix xyz.domain.com in URL rewrite section

I am providing rules for redirecting our site traffic from non-wwww/http to www/https path. I have entered the following rules:

<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>

It is working for all network traffic but it also accept wildcard literals also in domain name like entering ww.domain.com, myname.domain.com will also lead to the site and this gives SSL certificate warning prompt by browser.

在此输入图像描述

Any idea if I need to add/edit rules ?

Because domain.com does not match www.domain.com it will not do the SSL connection. And because the HTTP redirect can only be done once the SSL connection is established it will not be able to do the redirect. Your only chance is do get a certificate which includes domain.com and www.domain.com.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM