【发布时间】:2017-12-27 17:22:24
【问题描述】:
我已经建立了几个例子,第一个是使用Condition 元素来捕获我需要的其余网址的长手版本。这可行,但我不明白为什么以下更简洁的示例不起作用。
<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>
然后我有一个小改动的示例,但随后中断并且与我的测试 url 不匹配。
见Match Url结尾
d{4}\/)
参见参考Action Url
{R:2}/视频库
<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>
这里有一些示例测试应该将my-videos 替换为videogallery
请求: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
【问题讨论】:
-
您能否在您的示例中添加您希望重定向到的网址。它将帮助我为您建立更好的规则
-
全部设置@victor