0

I have two different rewrite rules.

<rule name="Venue" stopProcessing="true">
    <match url="Venue/([_0-9a-z-(-)-,-]+)/([_0-9a-z-(-)-,-]+)" />
    <action type="Rewrite" url="Main.asp?Type=Venue&amp;VenueID={R:1}&amp;VName={R:2}" appendQueryString="true" />
 </rule>
 <rule name="Venue" stopProcessing="true">
    <match url="Venue/([_0-9a-z-(-)-,-]+)/([_0-9a-z-(-)-,-]+)/([_0-9a-z-(-)-,-]+)" />
    <action type="Rewrite" url="Main.asp?Type=Venue&amp;VenueID={R:1}&amp;VName={R:2}&amp;ConcertID={R:3}" appendQueryString="true" />
  </rule>

Is there a way to combine both rules into a single rule using <conditions>?
So when you go to either URL.

/Venue/37/The_Omni (You go to its page.)

/Venue/37/The_Omni/ConcertID/1 (You go to its page.)

(OR) Will I have to settle with two rules but with different names?

1 Answer 1

0

Literally regular expression rules allow you to write,

<rule name="Venue" stopProcessing="true">
    <match url="Venue/([_0-9a-z-(-)-,-]+)/([_0-9a-z-(-)-,-]+)(?:/([_0-9a-z-(-)-,-]+))?" />
    <action type="Rewrite" url="Main.asp?Type=Venue&amp;VenueID={R:1}&amp;VName={R:2}{R:3:+&amp;ConcertID={R:3}}" appendQueryString="true" />
</rule>

You might try and see if IIS URL Rewrite module supports such expressions.

Sign up to request clarification or add additional context in comments.

2 Comments

I've been checking through pages of information but cannot find anything remotely close to what I am hoping for. It is not going to break me if it cannot be done. I was just wondering if it was possible. The site is already set up with both with their own names.
Have you tried the rules above? Does it work properly?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.