问题
I have setup a URL rewrite in IIS 7 for a particular site, that has 2 bindings.
- main.mydomain.com
- 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>
来源:https://stackoverflow.com/questions/16898477/point-a-domain-to-a-uri-of-an-iis-7-website-without-changing-the-domain