IIS and Web Servers
Having trouble with IIS redirect
Gravatar is a globally recognized avatar based on your email address. Having trouble with IIS redirect
  Michael Hogan (Ideate Hosting)
  All
  Apr 3, 2025 @ 01:35pm

I'm having to add a parameter to the end of a specific URL using IIS rules - and I'm having trouble.

When someone hits the url: https://lakepointe1.condoconduit.com/LakePointe1/ListMessages.cdo I want to add a parameter to the end of the request URL like this: https://lakepointe1.condoconduit.com/LakePointe1/ListMessages.cdo?CondoCode=M40GGRBB

I created this inbound rule in IIS but it's not redirecting in my browser so I must have something wrong:

Please advise!

Gravatar is a globally recognized avatar based on your email address. re: Having trouble with IIS redirect
  Michael Hogan (Ideate Hosting)
  Michael Hogan (Ideate Hosting)
  Apr 3, 2025 @ 02:21pm

Simplified:

<rule name="Lakepointe1 Discussions" stopProcessing="true">
      <match url="(.*)/LakePointe1/ListMessages.cdo(.*)" />
      <conditions>
            <add input="{QUERY_STRING}" pattern="CondoCode=M40GGRBB" negate="true" />
      </conditions>
      <action type="Redirect" url="{R:0}" appendQueryString="true" />
</rule>
Gravatar is a globally recognized avatar based on your email address. re: Having trouble with IIS redirect
  Rick Strahl
  Michael Hogan (Ideate Hosting)
  Apr 4, 2025 @ 02:50pm

What are you trying to do? Add to the query string? The code you have in <conditions> is checking for that query string - ie. it's a match query not adding anything.

I think if you want to add something you have to add it to url={R:0}?query=value... or if you need to pull it off the URL you can use one of the match groups (ie. {R:1} or {R:2} in your query).

Not exactly the same, but I do something similar with my new Help Documentation solution where I convert from the old syntax to new:

        <rewrite>
            <rules>
                <!-- Html Help Builder routing -->
                <rule name="Extract Topic ID" stopProcessing="true">
                    <match url="(_.*).html?$" />           
                    <action type="Redirect" url="https://{HTTP_HOST}/docs/?topic={R:1}" redirectType="Permanent" />
                </rule>
            </rules>
        </rewrite>

In this case I want to actually redirect to let search engines know that a different url should be used but the same would work with the url as you're doing.

+++ Rick ---

© 1996-2025