Asp.net mvc 当从HTTPS协议发出请求时,IIS URL重写规则(模式)无法识别{HTTP_HOST}

Asp.net mvc 当从HTTPS协议发出请求时,IIS URL重写规则(模式)无法识别{HTTP_HOST},asp.net-mvc,url-rewriting,asp.net-core-mvc,iis-8,url-rewrite-module,Asp.net Mvc,Url Rewriting,Asp.net Core Mvc,Iis 8,Url Rewrite Module,我有域名。 “example.com” 我想将所有流量重定向到“”(因为我有只对“www.example.com”有效的证书) 当我键入“”时,它工作正常,并按预期将我重定向到“” 问题:当我用“”发出请求时,它不会按规则重定向到“”。不知道为什么https会失败 以下是我应用的规则详细信息。 <rule name="example.com to https://www.example.com" enabled="true" stopProcessing="true"> &

我有域名。 “example.com” 我想将所有流量重定向到“”(因为我有只对“www.example.com”有效的证书) 当我键入“”时,它工作正常,并按预期将我重定向到“”

问题:当我用“”发出请求时,它不会按规则重定向到“”。不知道为什么https会失败

以下是我应用的规则详细信息。

<rule name="example.com to https://www.example.com" enabled="true" stopProcessing="true">
     <match url="(.*)" />
     <conditions>
          <add input="{HTTP_HOST}" pattern="^example\.com$" />
     </conditions>
          <action type="Redirect" url="https://www.example.com/{R:1}" />
</rule>

试试这个:

           <rule name="Add www" patternSyntax="Wildcard" stopProcessing="true">
                <match url="*" />
                <conditions>
                    <add input="{HTTP_HOST}" pattern="www.example.com" negate="true" />
                </conditions>
                <action type="Redirect" url="http://www.example.com/{R:1}" />
            </rule>


我必须使用https将“example.com”重定向到“www.example.com”。在这种情况下,如果我用“它将打开”https://example.com发出请求,这将给我证书错误。“http://example.com”{http\u HOST}=example.com,或“http://www.example.com'{http\u HOST}=www.example.com@ajinkya”