Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I have rule:

 <rule name="main" stopProcessing="true">
      <match url="main/([^.]*)/$" />
      <action type="Redirect" url="/main/" appendQueryString="false" redirectType="Permanent" />
 </rule>

References /main/xxxx/ go to /main/, but I need make rule with one reference (/main/docs/) whitch doesn`t have redirect.

Help me please make exception in rule

question from:https://stackoverflow.com/questions/65950629/how-add-exception-in-iis-url-rewrite-asp-net-core

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
16.0k views
Welcome To Ask or Share your Answers For Others

1 Answer

References /main/xxxx/ go to /main/, but I need make rule with one reference (/main/docs/) whitch doesn`t have redirect.

To achieve the requirement, you can try to add a condition to the rule, like below.

<rule name="main" stopProcessing="true">
    <match url="main/([^.]*)/$" />
    <conditions>
        <add input="{REQUEST_URI}" pattern="main/doc/" negate="true" />
    </conditions>
    <action type="Redirect" url="/main/" appendQueryString="false" redirectType="Permanent" />
</rule>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...