Asp.net mvc IIS重写从HTTPS中删除H
我在IIS Url重写方面遇到问题。在第一条规则之后,似乎一切正常,但是传递到第二条规则的url在模式上没有“h”。我得到了一个跟踪,输入的url是: product/car.aspx 然后通过以下第一条规则: 但接下来的规则将在url中传递: ttps://fo.bar.com/product/car.aspx 对此有任何想法都会很好。下面是我在web.config中的规则Asp.net mvc IIS重写从HTTPS中删除H,asp.net-mvc,iis,url-rewriting,Asp.net Mvc,Iis,Url Rewriting,我在IIS Url重写方面遇到问题。在第一条规则之后,似乎一切正常,但是传递到第二条规则的url在模式上没有“h”。我得到了一个跟踪,输入的url是: product/car.aspx 然后通过以下第一条规则: 但接下来的规则将在url中传递: ttps://fo.bar.com/product/car.aspx 对此有任何想法都会很好。下面是我在web.config中的规则 <system.webServer> <rewrite> <cl
<system.webServer>
<rewrite>
<clear />
<rule name="HTTP to HTTPS" stopProcessing="false">
<match url="(.*)" />
<conditions logicalGrouping="MatchAll">
<add input="{HTTPS}" pattern="^OFF$" />
<add input="{HTTP_HOST}" matchType="Pattern" pattern="^localhost(:\d+)?$" negate="true" />
<add input="{HTTP_HOST}" matchType="Pattern" pattern="^127\.0\.0\.1(:\d+)?$" negate="true" />
</conditions>
<action type="Rewrite" url="https://{HTTP_HOST}/{R:1}" />
</rule>
<rule name="Remove incorrect first char from query string" enabled="false" stopProcessing="true">
<match url="(.*)"/>
<conditions logicalGrouping="MatchAll" trackAllCaptures="true">
<add input="{QUERY_STRING}" pattern="^\&(.*)"/>
</conditions>
<action type="Rewrite" url="{R:0}?{C:1}" appendQueryString="false"/>
</rule>
..................
..................
从这个问题来看,您似乎只想将所有HTTP流量重定向到HTTPS
如果是这样,您可以将规则简化为:
<rule name="HTTP to HTTPS" patternSyntax="Wildcard" stopProcessing="true">
<match url="*" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTPS}" pattern="off" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Found" />
</rule>