我正在尝试编写一条规则,以根据特定条件将网站路由到特定URL。
例如,我的网站是http://www.sportStore.com/site/department/123
。我想要的是如果我输入http://www.sportStore.com/site/department/999
,那么它应该路由到https://www.sportStore.com/items/
。怎么做?我尝试了以下无效的方法。
代码:
<rule name="Site Redirect" enabled="true" stopProcessing="true">
<match url="site/department/(.*)" />
<action type="Redirect" url="https://www.sportStore.com/items/" appendQueryString="false" redirectType="Permanent" />
<conditions logicalGrouping="MatchAny">
<add input="{QUERY_STRING}" pattern="((123)|(456)|(789)|(111)|(222)|(333))" negate="true" />
</conditions>
</rule>
实际结果:
http://www.sportStore.com/site/department/123 -> https://www.sportStore.com/items/
http://www.sportStore.com/site/department/456 -> https://www.sportStore.com/items/
http://www.sportStore.com/site/department/999 -> https://www.sportStore.com/items/
预期结果:
http://www.sportStore.com/site/department/123 -> http://www.sportStore.com/site/department/123
http://www.sportStore.com/site/department/456 -> http://www.sportStore.com/site/department/456
http://www.sportStore.com/site/department/999 -> https://www.sportStore.com/items/
答案 0 :(得分:0)
仅对永久重定向999部门尝试以下规则。您显然可以在匹配网址格式中添加其他部门ID:
<rule name="Site Redirect" enabled="true" stopProcessing="true">
<match url="site/department/((999))" />
<action type="Redirect" url="https://www.sportStore.com/items/" appendQueryString="false" redirectType="Permanent" />
</rule>