IIS redirect with query stringRSS

2 replies

Last post Feb 16, 2021 10:08 PM by Wayne State CLAS

  • IIS redirect with query string

    Feb 15, 2021 06:44 PM|Wayne State CLAS|LINK

    Hello,

    We tried to reply to this thread but it's closed.

    We have redirects currently set up to go from oldsite.com to newsite.com using a rewrite map. They work except when a parameter is passed through the URL, ex. http://oldsite.com?utm_source=fb.com&utm_medium=direct&utm_campaign=quick-access&utm_content=, still goes to the old page instead of redirecting to the new page with the parameters, ex. http://newsite.com?utm_source=fb.com&utm_medium=direct&utm_campaign=quick-access&utm_content=.

    This is what I have:

    <rule name="Redirects to New Site">
                        <match url="(.*)" />
                        <conditions trackAllCaptures="true">
                            <add input="{RelaunchRedirects:{REQUEST_URI}}" pattern="(.+)" />
                        </conditions>
                        <action type="Redirect" url="http://newsite.com/{C:0}" appendQueryString="true" redirectType="Permanent" />
                </rule>

    Any ideas how what we're missing here?

    Thank you!

  • Re: IIS redirect with query string

    Feb 16, 2021 08:20 AM|samwu|LINK

    Hi Wayne State CLAS,

    Wayne State CLAS

    <add input="{RelaunchRedirects:{REQUEST_URI}}" pattern="(.+)" />
                        </conditions>

    How do you use url rewrite mapping?  you can use frt for url rewrite to get error information in iis.

    https://docs.microsoft.com/en-us/iis/extensions/url-rewrite-module/using-failed-request-tracing-to-trace-rewrite-rules

    Best regards,

    Sam

    .NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
  • Re: IIS redirect with query string

    Feb 16, 2021 10:08 PM|Wayne State CLAS|LINK

    Thank you for helping with this. We finally figured it out. The correct code should've used "URL" instead of "URI".

    <add input="{RelaunchRedirects:{URL}}" pattern="(.+)" />

    Many thanks!