Point a domain to a URI of an IIS 7 website without changing the domain

北慕城南 提交于 2019-12-11 09:18:30

问题


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>


来源:https://stackoverflow.com/questions/16898477/point-a-domain-to-a-uri-of-an-iis-7-website-without-changing-the-domain

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!