Regex 基于URL中的参数将IIS URL从一个域重写到其他域的正则表达式
我有一组URL,我想根据URL中ID参数的值将其重写到其他域: -->需要重写为: -->需要重写为: -->需要重写为:Regex 基于URL中的参数将IIS URL从一个域重写到其他域的正则表达式,regex,iis,url-rewriting,Regex,Iis,Url Rewriting,我有一组URL,我想根据URL中ID参数的值将其重写到其他域: -->需要重写为: -->需要重写为: -->需要重写为: 我发现有几篇文章解释了如何设置重写规则,但没有一篇与上述场景相匹配。有什么想法吗?这是否可行?我们可以使用Path\u Info服务器变量来匹配URL段中的ID参数。请参考下面的代码片段 <system.webServer> <rewrite> <rules>
我发现有几篇文章解释了如何设置重写规则,但没有一篇与上述场景相匹配。有什么想法吗?这是否可行?我们可以使用
Path\u Info
服务器变量来匹配URL段中的ID参数。请参考下面的代码片段
<system.webServer>
<rewrite>
<rules>
<rule name="MyRule" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{PATH_INFO}" pattern="\/community\/([0-9]+)(.*)" />
</conditions>
<!--{C:1} is the value of id, {C:2} is the rest of the URL segment. it is referred by the above condition.-->
<action type="Redirect" url="http://{mymap:{C:1}}{C:2}" />
</rule>
</rules>
<rewriteMaps>
<rewriteMap name="mymap" defaultValue="">
<add key="12345678" value="www.bing.com"></add>
<add key="44566336" value="www.microsoft.com"></add>
</rewriteMap>
</rewriteMaps>
</rewrite>
</system.webServer>
如果有什么我能帮忙的,请随时告诉我