question

JoeNalducci-0885 avatar image
0 Votes"
JoeNalducci-0885 asked BruceZhang-MSFT answered

URL Rewrite Help

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-server-iis
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

BruceZhang-MSFT avatar image
0 Votes"
BruceZhang-MSFT answered

Hi @JoeNalducci-0885,

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






1.jpg (105.8 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.