将域指向IIS 7网站的URI而不更改域 [英] Point a domain to a URI of an IIS 7 website without changing the domain

查看:99
本文介绍了将域指向IIS 7网站的URI而不更改域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在IIS 7中为特定网站设置了一个URL重写,它有2个绑定。

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

我还应用了URL重写规则,如下所示:

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

在条件
下匹配(。*)
然后
其中 {HTTP_HOST} 匹配 ^ hub\.mydomain\.com $

301重定向到

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

这是有效的,目的是让 hub.mydomain.com 将用户定向到的URI> 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

我现在被要求更改此项,以便 hub.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.

如何实现这一目标?我认为顾名思义,URL Rewrite不再适用?如果是这样我怎么能这样做?

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?

编辑:

main.mydomain.com 仍需要访问网站的根目录。

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

推荐答案

在您的问题中,您声明 main.mydomain.com hub.mydomain.com 绑定到单个网站。

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

因此,如果您希望点击 hub.mydomain.com 的用户与内容来自 http://main.mydomain.com/hub/home.html ,相当于让他们点击 hub.mydomain.com 并从 http://hub.mydomain.com/hub/home.html 中删除​​内容。

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.

您的规则将如下:

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

这篇关于将域指向IIS 7网站的URI而不更改域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆