简体   繁体   中英

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.

eg "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.

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>

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM