URL Rewrite Help

Joe Nalducci 1 Reputation point
2021-07-15T00:05:36.99+00:00

Hello,

 New to the URL Rewrite configuration but I have a time sensitive need and was looking to see if someone can point me in the right direction.

 Been reading through the docs but can 't get this to work.  Need to redirect to a new domain name, and replace some parameters and then append the remaining parameters.

Looking to do a redirect for a URL like this:

http://www.domainA.com/folder1/folder2/?@accountID=1&SiteID=2&subname=joe

to be rewritten as

  http://www.domainB.com/folder1/folder2/?@accountID=100&SiteID=2007&subname=joe

So the @accountID=1&SiteID=2@ gets put in the redirect as a static entry, and append the what ever is after &subname=

setup the match URL to capture the part I want to append and my rewrite is like this:

  http://www.domainB.com/folder1/folder2/?@accountID=100&SiteID=2007{R:3}

But it does not work at all.

Help.

Windows development | Internet Information Services
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce Zhang-MSFT 3,771 Reputation points
    2021-07-15T05:15:16.477+00:00

    Hi @Joe Nalducci ,

    According to your description, I wrote a rule and test it very well. You can try it.

     <rewrite>  
                <rules>  
                    <rule name="rule1">  
                        <match url="(folder1)/(folder2)/(.*)" />  
                        <conditions>  
                            <add input="{QUERY_STRING}" pattern="(@accountID=([0-9]+))&amp;(SiteID=([0-9]+))&amp;(.*)" />  
                        </conditions>  
                        <action type="Rewrite" url="http://localhost:801/{R:1}/{R:2}/?@accountID=100&amp;SiteID=2007&amp;{C:5}" appendQueryString="false" />  
                    </rule>  
                </rules>  
            </rewrite>  
    

    114902-1.jpg

    Please use failed request tracing to find out the issue of your rule.


    If the answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our  documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Best regards,
    Bruce Zhang

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.