简体   繁体   中英

IIS rewrite rule not working

I would like to rewrite this: domain.com/gallery/123123/name-of-the-image/

To display content from here: domain.com/gallery/showImage/name-of-the-image-123123

Here's my current code:

<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>

How should I alter the rewrite code to make it work?

Big thanks in advance

Your regex to match the URL should be:

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

and the rewrite URL should be:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM