URL 路由,从domain.com/dir/ 到otherDomain.com?
如果我在 myFirstDomain.com/dir/ 有一个网站,是否可以让 mySecondDomain.com 指向 myFirstDomain.com/dir/,以便当用户浏览定向站点时,他们只能看到 mySecondDomain.com/potentialSubDirFromMyFirstDomain/ 或它是如何运作的?
If I have a website at myFirstDomain.com/dir/, is it possible to get mySecondDomain.com to point to myFirstDomain.com/dir/ so that when users browse at the directed site, they only see mySecondDomain.com/potentialSubDirFromMyFirstDomain/ or how does it work?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
好吧,很好。
那么您需要做的是使用 IIS 6.0 主机标头过滤器。
本质上,在 IIS 中,您将拥有当前为 myFirstDomain.com 提供服务的默认网站。
通过主机标头,我们可以添加另一个网站,该网站映射到您的子目录的位置,并且仅当用户通过“mySecondDomain.com”输入时才可见。
简而言之,我们让 IIS 在一台机器上托管多个站点。我对 IIS 6.0 中的过程不太熟悉,因为我使用的只是 IIS 7.0,它在 Windows Server 2003 上不可用。
但是,以下链接应该可以帮助您在 IIS 6.0 中实现它:
http://www.microsoft.com/ technet/prodtechnol/WindowsServer2003/Library/IIS/b77cf015-017f-489c-9b5b-65ca4a679392.mspx?mfr=true
http://forums.iis.net/t/1120787.aspx
http://www.goarticles.com/cgi-bin/showa.cgi?C=188629
这个想法是,当用户输入“mySecondDomain.com”时,它会将此“主机标头”添加到从浏览器到 IIS 的 HTTP 请求正文中,然后 IIS 将读取该值并检查是否有任何网站包含主机标头的匹配项,并将用户重定向到适当的网站,因此 mySecondDomain.com 将显示为好像在自己的服务器上(技术上无论如何都是如此。)
据我所知,主机标头属性仅存在于 HTTP 1.1 协议中,HTTP 1.0 不支持它并且不会发送IIS 的主机头,这意味着将显示默认网站...(无论您来自哪个域)。我很确定大多数浏览器都使用 HTTP 1.1。
一种更安全的方法是通过 IP 地址绑定每个网站...但是为此,您将需要在一个盒子上有多个互联网 IP 地址 - 不过我从来没有遇到过主机标头问题!
Ok good.
Well what you'll need to do is make use of IIS 6.0 Host Header Filter.
Essentially in IIS you will have your default web site which is currently serving myFirstDomain.com.
With Host Headers, we can add another web site which is mapped to the location of your subdirectory and will only be visible if the user enters via 'mySecondDomain.com'.
So in a nutshell we are getting IIS to host multiple sites on one box. I'm not too familiar with the process in IIS 6.0 since all I use is IIS 7.0 which is not available on Windows Server 2003.
However, the following links should help you implement it in IIS 6.0:
http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/b77cf015-017f-489c-9b5b-65ca4a679392.mspx?mfr=true
http://forums.iis.net/t/1120787.aspx
http://www.goarticles.com/cgi-bin/showa.cgi?C=188629
The idea is that when a user types 'mySecondDomain.com' it will add this 'host header' into the body of the HTTP request from the browser to IIS, IIS will then read this value and check to see if any of the website(s) contain a match for the host header and redirect the user to the appropriate website, thus mySecondDomain.com will appear as though its on its own server (which it technically is anyway.)
From what I remember the host header attribute only exists in the HTTP 1.1 protocol, HTTP 1.0 does not support it and will not send the host header to IIS which means the default web site will be displayed instead...(regardless of what domain you come in from). I'm pretty sure most browsers are using HTTP 1.1 though.
A safer way would be to bind each web site via IP address... but for this you will need multiple internet ip addresses on one box - I've never had a problem with host headers though!
首先,我认为您需要直接访问网络服务器...您使用的是 VPS/专用服务器还是共享主机?
Windows 服务器、Linux?
Firstly, I think your going to need direct access to the web server... are you using a VPS/Dedicated Server or Shared Hosting?
Windows Server, Linux?
对于 DNS 来说这是不可能的。您必须设置 HTTP 重定向(没有 IIS 经验,所以我无法在这里提供帮助,只是建议您删除“dns”标记)。
It is not possible at all with the DNS. You will have to set up a HTTP redirection (no experience with IIS so I cannot help here, just suggest you to drop the "dns" tag).