We help IT Professionals succeed at work.

IIS - Multiple URL Rewrite Rules with different names. etc... domain.com/One/itemhere and domain.com/Two/itemhere

Hello, all.

When creating my own URL Rewrite script with the error pages, I was able to do multiple redirects.
However, with IIS URL Rewrite, I am having an issue with it.

So, this is what I believe I need to do.


QueryStrings
domain.com/Main.asp?Type=One&OneID=1
domain.com/Main.asp?Type=Two&TwoID=1
domain.com/Main.asp?Type=Three&ThreeID=1

What it needs to be.
domain.com/One/ItemHere
domain.com/Two/ItemHere
domain.com/Three/ItemHere

This works, as it is grabbing everything, so everything you put in with: domain.com/something
Will get sent to this RULE.
                <rule name="BandMember" stopProcessing="true">
                    <match url="([_0-9a-z-(-)-,-]+)" />
                    <conditions>
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="Main.asp?Type=One&amp;BMID={R:1}" logRewrittenUrl="true" />
                </rule>

Open in new window

This does not??
I am thinking the "match url=" needs to have something similar in it, but, not this.
                <rule name="Label" stopProcessing="true">
                    <match url="Two/([_0-9a-z-(-)-,-]+)" />
                    <conditions>
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="Main.asp?Type=Two&amp;LabelID={R:1}" logRewrittenUrl="true" />
                </rule>

Open in new window


Any ideas on doing Multiple Rules, as I demonstrated above?

Wayne
Comment
Watch Question

Author, Web Developer
Top Expert 2009
Commented:

Here is the solution I came up with, and it works like a charm.

[code]

<rule name="One" stopProcessing="true">
    <match url="One/([_0-9a-z-(-)-,-]+)" />
    <action type="Rewrite" url="Main.asp?Type=One&LabelID={R:1}" appendQueryString="true" />
</rule>
<rule name="Two" stopProcessing="true">
    <match url="Two/([_0-9a-z-(-)-,-]+)" />
    <action type="Rewrite" url="Main.asp?Type= Two &BMID={R:1}" appendQueryString="true" />
</rule>

[/code]