IIS rewrite rule to redirect to new domain with query string value passed

47 views Asked by At

I'm unable to figure out the IIS url rewrite rule, hopefully someone can help. I want to create a redirect rule (302-found)

from:

domain1.com/?kb=8

to:

domain2.com/view/8

Thank you.

1

There are 1 answers

3
samwu On BEST ANSWER

You can try this rule:

<rule name="test" stopProcessing="true">   
  <match url="(.*)" />  
    <conditions>  
      <add input="{HTTP_HOST}" pattern="domain1.com" />  
      <add input="{QUERY_STRING}" pattern="kb=(.*)" />  
    </conditions>  
  <action type="Redirect" url="https://domain2.com/view/{C:1}" />  
</rule>