0
votes

I am trying to use iis url rewrite module to redirect the post requests with query string to some other url in the same domain. For example:

Original request url: https://www.example.com/ABC/DEF/GHI/JKL?q=<variableValue>&t=<variableValue>

Redirected URL: https://www.example.com/DEF/GHI/JKL?q=<variableValue>&t=<variableValue>

Request method is POST and it should be redirected using the same method with same request data and query string. I am not able to find an example. This is what I am trying to follow: https://docs.microsoft.com/en-us/iis/extensions/url-rewrite-module/creating-rewrite-rules-for-the-url-rewrite-module

1
you could try this rule:<rule name="query string redirect" stopProcessing="true"><match url="(.*)" /> <conditions> <add input="{HTTP_HOST}" pattern="www.domain1.com" /> <add input="{HTTPS}" pattern="on" /> <add input="{REQUEST_URI}" pattern="/ABC/DEF" /> <add input="{QUERY_STRING}" pattern="q\=([a-zA-Z0-9]+)\&amp;t=([a-zA-Z0-9]+)" /></conditions><action type="Redirect" url="http://www.domain1.com/DEF/GHI/JKL?q={C:1}&amp;t={C:2}" appendQueryString="false" /> </rule>Jalpa Panchal
Is your issue solved? If your issue is solved then I suggest you to mark the helpful suggestion as an answer.Jalpa Panchal

1 Answers

1
votes

you could try this rule

<rule name="query string redirect" stopProcessing="true"><match url="(.*)" />
 <conditions> 
<add input="{HTTP_HOST}" pattern="www.domain1.com" /> 
<add input="{HTTPS}" pattern="on" /> 
<add input="{REQUEST_URI}" pattern="/ABC/DEF" />
<add input="{QUERY_STRING}" pattern="q\=([a-zA-Z0-9]+)\&amp;t=([a-zA-Z0-9]+)" />
</conditions>
<action type="Redirect" url="http://www.domain1.com/DEF/GHI/JKL?q={C:1}&amp;t={C:2}" appendQueryString="false" />
</rule>