我已经建立了几个示例,第一个是使用Condition
元素来捕获我需要的其余网址的长手版本。这工作,但我不明白为什么下面更简洁的例子不起作用。IIS网址重写匹配无法正常工作
<rule name="my-videos">
<match url="(.*)(trips\/[\w-]+\/[\w-]+\/[\w-]+\/\d{4})" />
<conditions>
<add input="{URL}" pattern="my-videos(.*)" />
</conditions>
<action type="Redirect" url="{R:2}/videogallery{C:1}" redirectType="Permanent" />
</rule>
然后,我有一个小的变化这个例子中,但随后断裂和不符合我的测试网址。
见的Match Url
d{4}\/)
端和参见参考文献Action Url
{R:2}/videogallery
<rule name="my-videos">
<match url="(.*)(trips\/[\w-]+\/[\w-]+\/[\w-]+\/\d{4}\/)" />
<conditions>
<add input="{URL}" pattern="my-videos(.*)" />
</conditions>
<action type="Redirect" url="{R:2}videogallery{C:1}" redirectType="Permanent" />
</rule>
然后理想地,组合最终版本,而不Condition
元件
<rule name="my-videos">
<match url="(.*)(trips\/[\w-]+\/[\w-]+\/[\w-]+\/\d{4}\/)my-videos(.*)" />
<action type="Redirect" url="{R:2}videogallery{R:3}" redirectType="Permanent" />
</rule>
下面是一些例子测试应与videogallery
更换my-videos
要求:trips/my-adventures/asia/india/2018/my-videos
预计:trips/my-adventures/asia/india/2018/videogallery
要求:trips/my-adventures/asia/india/2018/my-videos?fullscreen=true
预计:trips/my-adventures/asia/india/2018/videogallery?fullscreen=true
要求:trips/my-adventures/asia/india/2018/my-videos/vines
预计:trips/my-adventures/asia/india/2018/videogallery/vines
要求:trips/my-adventures/asia/india/2018/my-videos/vines?fullscreen=true
预计:trips/my-adventures/asia/india/2018/videogallery/vines?fullscreen=true
能否请您添加到你的前你想要重定向到哪个url。它会帮助我为你制定更好的规则 –
All set @victor –