简体   繁体   中英

Same site to be hosted on multiple port in IIS

I have one website which is running on 443 port on a particular DNS ( https://mypage.com:443/login ). Now, I want to redirect the same to a new site (mynewsite.com:443). I have done using redirect option in the sites in IIS where I have given redirect URL as https://mynewsite.com:443 . All the requests which are coming to https://mypage.com:443/login is successfully getting redirected to https://mynewsite.com:443

Now, I have another DNS (https://mysecondDNS:443). I want that users who are accessing this https://mysecondDNS:443 should be redirected to https://mypage.com:443/login ONLY.

But the users who are directly accessing https://mypage.com:443/login should go into https://mynewsite.com:443

Can this be achieved in IIS.

What I have tried till now is, I have another site with port 8080/8081 and tried for redirecting, but that does not seems to be working.

Can some one pls help me or guide me how to achieve this.

thanks

I came up with another solution to your problem, and it is feasible after testing. You can add custom headers during the rewriting process.

In my test, I created three sites corresponding to your three domain names, mynewsite.com myscondDNS.com and mypage.com . They all have their own pages.

When users visit mysecondDNS.com , they will be redirected to mypage.com . According to your description, the page of mypage.com should be displayed. Only when users directly visit mypage.com will request be redirected to mynewsite.com .

In order to facilitate the URL rewrite module to recognize the request, when mysecondDNS.com redirected to mypage.com , I added a custom header HTTP_REQ_from (the header must be start with HTTP_ ) and assigned the value mysecondDNS to it. When mypage.com is redirected to mynewsite.com , the header will be judged. If the header value matches, the request will not be redirected, and will be redirected to mynewsite.com if it does not.

This is rule to add custom header

<rule name="rule">
                <match url=".*" />
                <action type="Rewrite" url="http://mypage.com" />
                <serverVariables>
                    <set name="HTTP_REQ_from" value="mysecondDNS" />
                </serverVariables>
 </rule>

This is rule to judge custom header

<rule name="rule">
                <match url=".*" />
                <conditions>
                    <add input="{HTTP_REQ_from}" pattern="mysecondDNS" negate="true" />
                </conditions>
                <action type="Rewrite" url="http://mynewsite.com" />
            </rule>

Log in failed request tracing, mysecondDNS to mypage, will not redirect to mynewsite 在此处输入图像描述

在此处输入图像描述

mypage redirect to mynewsite(the request send by user, no HTTP_REQ_from in header) 在此处输入图像描述

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