简体   繁体   中英

Rewrite rule pattern

I am trying to create a rewrite rule from:
mywebsite.com/lorem/subpage
To
mywebsite.com/ipsum/subpage

So the subpage has to be forwarded but the parent page should be different.

This is my try so far:

<rule name="Redirect rule" stopProcessing="true">
    <match url="(.*)" />
    <conditions logicalGrouping="MatchAny" trackAllCaptures="false">
        <add input="{URL}" pattern="^/lorem" />
    </conditions>
    <action type="Redirect" url="/ipsum/{R:1}" redirectType="Permanent" />
</rule>

Problem: {R:1) just pastes the entire URL. What should it be instead?

First, change {URL} to {REQUEST_URI} . Set pattern to "lorem/(.*)" . It will match lorem/subpage .

Then change {R:1} to {C:1} . {R:1} means the content in <match url="(.*)" /> . Only {C:1} means content in Conditions .

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