Edmilson Lani
Edmilson Lani

Reputation: 153

IIS: Redirect subdomain to specific url

In IIS 8, I want to redirect the url http://test.example.com to http://www.example.com/abc/123

I try this, but not work.

<rule name="test" stopProcessing="true">
    <match url="^test.example.com$" />
    <action type="Redirect" url="http://www.example.com/abc/123" />
</rule>

Upvotes: 0

Views: 1846

Answers (2)

Joseph M Tsai
Joseph M Tsai

Reputation: 568

you could add the pattern like this

<rule name="RedirectDomain" enabled="true" stopProcessing="true">
        <match url=".*" />
        <conditions logicalGrouping="MatchAny" trackAllCaptures="true">
            <add input="{HTTP_HOST}" pattern="(.*)test.example.com />
        </conditions>
        <action type="Redirect" url="http://www.example.com/abc/123" redirectType="Permanent" />
    </rule>

Upvotes: 1

SImonThrane
SImonThrane

Reputation: 25

In the IIS GUI on the given side you should be able to choose 'HTTP Redirect' from there you can type in a url to redirect the site to. I don't know if this approach is the recommended (It is normally used to redirect HTTP request on a given site to use HTTPS), but it will solve your problem.

Upvotes: 0

Related Questions