user3597763
user3597763

Reputation: 37

How to Redirect a Domain without Changing the URL in web.config file?

I setup a redirect from one domain (https://test.mydomain.com) to another URL (http://testing.com/test/Login.aspx) and I want to keep the domain name in the address bar. Basically, Redirect website visitors to another site, but do not show them the destination address, so they do not know about the redirection.

This is for a windows server 2008 r2, running iis 7. I would like to amend the web.config file.

I expect the redirect to keep the original domain (https://test.mydomain.com).

Upvotes: 2

Views: 4921

Answers (1)

Brando Zhang
Brando Zhang

Reputation: 27962

According to your description, I suggest that you use URL Rewrite.
First add the condition to check whether URL is a https request, then add another condition to check the domain of URL. Add the rule below to your web.config file.

<rule name="test url rewrite">
    <match url="(.*)" />
    <conditions>
        <add input="{HTTPS}" pattern="on" />
        <add input="{HTTP_HOST}" pattern="test.mydomain.com" />
    </conditions>
    <action type="Rewrite" url="http://testing.com/test/Login.aspx" />
</rule>

Upvotes: 1

Related Questions