'IIS URL Rewrite - Change Beginning of URL
I would like to replace
https://web1.domain.org/cwweb/LauncherInterface.aspx?host=https://web1.domain.org/
with
https://web2.domain.org/cwweb/LauncherInterface.aspx?host=https://web2.domain.org/
and keep everything else after it.
e.g. "https://web2.domain.org/xxxxx/LauncherInterface.aspx?host=https://web2.domain.org/xxxxx&thisid=zzzz"
This is what I have tried:
<rewrite>
<rules>
<rule name="redirect app" stopProcessing="true">
<match url="^(.*)$" />
<conditions>
<add input="{HTTP_HOST}" pattern="web1.domain.org" />
</conditions>
<action type="Redirect" url="https://web2.domain.org/cwweb/LauncherInterface.aspx?host=https://web2.domain.org/{R:1}" />
</rule>
</rules>
</rewrite>
This is what it displays: ""https://web2.domain.org/xxxxx/LauncherInterface.aspx?host=https://web1.domain.org/xxxxx&thisid=zzzz"
The second domain name doesn't change.
I pretty much a noob with this. Any assistance would be appreciated.
Solution 1:[1]
You can try this rule:
<rule name="test" stopProcessing="true">
<match url="^cwweb/LauncherInterface.aspx$" />
<conditions>
<add input="{HTTP_HOST}" pattern="web1.domain.org" />
<add input="{QUERY_STRING}" pattern="(.*)web1(\.domain\.org.*)" />
</conditions>
<action type="Redirect" url="https://web2.domain.org/{R:0}?{C:1}web2{C:2}" appendQueryString="false" />
</rule>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |