jpo
jpo

Reputation: 4059

URL rewrite and redirect between hosts

I have the following rewrite rule to redirect any conetnt from a host, hostA.com to the home page of a new host, hostB.com. I also want to browser url to change to www.HostB.com

<rewrite>
        <rules>
            <rule name="301 redirect entire site" stopProcessing="true">
                <match url="^hostA(.*)$" />
                <action type="Redirect" redirectType="Permanent" url="http://www.hostB.com" appendQueryString="true" />
            </rule>
        </rules>
    </rewrite>

But that does not work. How can I fix this please.

Upvotes: 0

Views: 423

Answers (1)

Saddam Abu Ghaida
Saddam Abu Ghaida

Reputation: 6739

you can doit like this

<rule name="domain redirect" enabled="true" stopProcessing="true">
      <match url="^hostA(.*)$" />
      <action type="Redirect" url="http://hostb.example.com/{R:0}" appendQueryString="true" />
  </rule>

Upvotes: 1

Related Questions