3

I just need to remove a specific part of any request that matches. See samples below:

Examples:

Old URLs: /learn/videos, /learn/events/event-1, /learn/resources/o365/lesson1

New URLs: /videos, /events/event-1, /resources/o365/lesson1

Do i need 3 seperate rules like below:

<rule name="old-learn-1">
  <match url="^learn/([_0-9a-z-]+)"/>
  <action type="Rewrite" url="{R:1}"/>
</rule>
<rule name="old-learn-2">
  <match url="^learn/([_0-9a-z-]+)/([_0-9a-z-]+)"/>
  <action type="Rewrite" url="{R:1}/{R:2}"/>
</rule>
<rule name="old-learn-3">
  <match url="^learn/([_0-9a-z-]+)/([_0-9a-z-]+)/([_0-9a-z-]+)"/>
  <action type="Rewrite" url="{R:1}/{R:2}/{R:3}"/>
</rule>

Or can it be done with 1 rule?

Any piece of advise or information would be highly appreciated.

4

1 回答 1

8

像这样的东西应该工作:

<rule name="old-learn-3">
  <match url="^learn/([/_0-9a-z-]+)"/>
  <action type="Rewrite" url="{R:1}"/>
</rule>

甚至

<rule name="old-learn-3">
  <match url="^learn/(.+)"/>
  <action type="Rewrite" url="{R:1}"/>
</rule>
于 2013-09-05T20:10:47.180 回答