简体   繁体   English

IIS中的多个网站指向相同的IP。 IIS如何映射到正确的网站?

[英]Multiple websites in IIS pointing to same IP. How does IIS map to correct website?

I have created two test websites in IIS. 我在IIS中创建了两个测试网站。 one is called testapp.com and other is called anothertestapp.com. 一个叫做testapp.com,另一个叫做anothertestapp.com。

在此输入图像描述

In my host files both testapp.com and anothertestapp.com is pointing to 127.0.0.1 在我的主机文件中,testapp.com和anothertestapp.com都指向127.0.0.1

both apps are loading perfectly in browser and show their respective contents. 两个应用程序都在浏览器中完美加载并显示其各自的内容。

The question however is, how does IIS knows that testapp.com is different than anothertestapp.com. 但问题是,IIS如何知道testapp.com与anothertestapp.com不同。 I mean when in browser I type two different domains they both actually are pointing to same IP (127.0.0.1), how does IIS map that to two different websites correctly? 我的意思是当我在浏览器中键入两个不同的域时,它们实际上都指向同一个IP(127.0.0.1),IIS如何正确映射到两个不同的网站?

When your browser loads a web page, one of the request headers it sends is the text of the domain name you typed in. This is the "Host" request header. 当您的浏览器加载网页时,它发送的其中一个请求标头是您输入的域名文本。这是“主机”请求标头。 IIS uses the value of this header to pick which web site will serve your request. IIS使用此标头的值来选择将为您的请求提供服务的网站。 The "bindings" on your IIS web site let you configure its host headers. IIS网站上的“绑定”允许您配置其主机标头。

Here's another question that explains the "Host" header in more detail: What is http host header? 这是另一个更详细解释“主机”标题的问题: 什么是http主机标头?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM