我有一个问题与iis url重写。在第一个规则之后,一切看起来都很好,但是传递到第二个规则的url在模式上没有“h”。我找到了一条线索,找到的网址是:
产品/汽车.aspx
然后通过下面的第一条规则:
https://fo.bar.com/product/car.aspx
但是下一条规则将在url中传递:
http://fo.bar.com/product/car.aspx
任何关于这个的想法都会很好。下面是我在web.config中的规则
<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>