Point a domain to a URI of an IIS 7 website withou

2019-08-04 00:37发布

问题:

I have setup a URL rewrite in IIS 7 for a particular site, that has 2 bindings.

  1. main.mydomain.com
  2. hub.mydomain.com

I have also applied a URL Rewrite Rule as shown below:

match (.*) and then under the condition where {HTTP_HOST} matches ^hub\.mydomain\.com$

301 redirect to

http://main.mydomain.com/hub/home.html

and this works, the purpose was to have hub.mydomain.com direct the user to a URI of http://main.mydomain.com/hub/home.html

I have now been asked to change this so that the hub.mydomain.com remains in the user's browser address but that they are shown the correct /hub/home.html content.

How can this be achieved? I presume that as the name suggests, URL Rewrite is no longer suitable? and if so how else can I do this?

EDIT:

main.mydomain.com still needs to go to the root of the website.

回答1:

In your question, you state that main.mydomain.com and hub.mydomain.com are binded to a single website.

So if you want the users who hit hub.mydomain.com to be shown with the content from http://main.mydomain.com/hub/home.html, it is equivalent to have them hit hub.mydomain.com and be shwon the content from http://hub.mydomain.com/hub/home.html.

You rule would then go as:

<rule name="hub rewrite">
    <match url="^/?$" />
    <conditions>
        <add input="{HTTP_HOST}" pattern="^hub\.mydomain\.com$" />
    </conditions>
    <action type="Rewrite" url="hub/home.html" />
</rule>