IIS重写规则无效

时间:2013-10-16 16:45:32

标签: iis url-rewriting

我想改写一下: domain.com/gallery/123123/name-of-the-image /

要显示此处的内容:domain.com/gallery/showImage/name-of-the-image-123123

这是我目前的代码:

<rule name="Gallery - Single image">
    <match url="^gallery/([0-9])/([a-z-/]+)/?$" />
    <conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
    <action type="Rewrite" url="gallery/showImage/{R:2}-{R:1}" />
</rule>

我应该如何更改重写代码才能使其正常工作?

提前非常感谢

1 个答案:

答案 0 :(得分:0)

与网址匹配的正则表达式应为:

^domain\.com\/gallery\/(\d+)\/([a-z-]+)\/?$

,重写网址应为:

domain.com/gallery/showImage/{R:2}-{R:1}