IIS7中不同的域对应不同的页面

发布于 2024-07-12 03:26:00 字数 415 浏览 5 评论 0原文

我在 IIS7 的默认网站内有一个默认网站和另一个 Web 应用程序(我们称之为Application2)。

我有 2 个注册域名,例如 www.example.comwww.example.net

我想配置一些东西,当我打开www.example.com时,我会得到默认网站,当我打开www.example.net时我得到默认网站/应用程序2

www.example.com -> Default Web Site
www.example.net -> Default Web Site/Application2

我怎样才能做到这一点?

I have a Default Web Site and another web application (let's call it Application2) inside the Default Web Site in IIS7.

I have 2 registered domain names, let's say www.example.com and www.example.net.

I would like to configure things that when I open www.example.com I get Default Web Site, when I open www.example.net I get Default Web Site/Application2.

www.example.com -> Default Web Site
www.example.net -> Default Web Site/Application2

How can I do that?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

软甜啾 2024-07-19 03:26:00

首先,您需要决定是否要使用基于名称的托管还是基于 IP 的托管。

基于 IP 使用唯一的 IP 来确定它将服务于哪个虚拟主机,而基于名称实际上将使用客户端浏览器发送的主机标头。

让我们看看两种场景:

场景#1(共享一个 IP)

您有一台只有一个 IP 的服务器,可以是私有的也可以是公共的,只要您所服务的域在为您内部或您的客户端提供服务的 dns 中正确配置即可外部(NAT)。

我建议为了本教程的目的,您停止默认网站。 好的。

您将在 II7 中设置一个站点并为其命名。 转到管理器的右侧,在操作菜单下查找“绑定”; 确保您在左侧窗格中选择了新站点。 现在,在“站点绑定”下,选择您将在站点之间共享的 IP 地址(基于名称的托管)。 在“主机名”下输入域名#1“www.example.com”,点击确定。

对其他一个或多个域执行上述相同的过程,确保它们具有不同的主机名和相同的 IP。

就是这样。 您现在可以启动这些站点并同时运行它们。

如果您使用“默认站点”,则上述原则同样适用。 “默认站点”只是 MS 为默认创建的一个名称。

场景#2(多个 IP 共享)

如果您有一些私有或公共 IP 可供使用,或者至少在您进行练习之前,这里唯一的区别是您将设置的站点并且不必指定“主机名” “每个站点,因为这基本上是在 DNS 区域本身完成的。 无论如何,这些站点都会响应端口 80 上向这些 IP 发出的任何请求。

您何时需要使用多个 Ip 来为网站提供服务。 好吧,这一切都取决于。

一些原因是:网络隔离(安全)、应用程序在基于名称的托管下无法正常工作、SSL 证书绑定 443(PRE II7) 以及对站点的大部分完全控制。 当然还有更多的原因,但我也会让其他人写一点。

玩得开心。

First you need to decide if your going to use Name Based or IP Based hosting.

IP-Based uses unique ip's to determine which virtual host it will serve and Name Based will actually use the host header which is sent by your client browser.

So let's see two scenarios:

Scenario # 1 (ONE IP TO SHARE)

You have a server with only one IP, could be either private or public as long as the domains you are serving are properly configured in the dns serving you internally or your client externally (NAT).

I suggest that for the sake of this tutorial you stop the default website. Ok.

You will set up one site in II7 and name it accordingly. Go to the right hand side of the manager and look for "Bindings" under actions menu; making sure you have the new site selected on your left pane. Now under "Site Bindings" select the ip address you will be sharing between the sites (name based hosting). Under "Hostname" enter domain # 1 "www.example.com", hit ok.

Follow the same procedure above with the other domain or domains, making sure they have diferent hostnames and same ip's.

That's it. You will now be able to start those sites and run them at the same time.

The same principle above applies if your using the "Default Site". "Default Site" is just a name MS gave the default created one.

Scenario # 2 (MULTIPLE IP TO SHARE)

If you have either some private or public ip to spare, or at least until you do the exercise the only diference here is that sites you will set up and don't have to specify the "Hostname" per each site, as this is basically done in the DNS zones itself. The sites will respond for any request made to those ip's on port 80 regardless.

When will you need to use multiple Ip's to serve websites. Well it all depends.

Some reasons are: Network Isolation (Security), Applications which don't work well under name based hosting, SSL Certificates Bindings 443(PRE II7), and mostly complete control over site. There are of course more reasons, but I'll let others write a bit also.

Have fun.

多像笑话 2024-07-19 03:26:00

编辑...经过进一步调查,我发现如果您可以设置多个站点并同时运行它们。 只需在设置主机值后停止并启动站点即可让它们同时运行。

原始帖子:

执行此操作的直接方法是通过打开 IIS 并右键单击“站点”,然后选择“添加网站”来添加另一个应用程序。 在那里,您可以指定 Application2 的物理路径,并将“主机”设置为“www.example.net”,这将过滤对您的第二个站点的所有请求。 任何与“www.example.net”不匹配的请求仍将转到默认网站。

这种方法在使用 IIS 的 Windows Server 上可以正常工作,但在 Vista 的 IIS7 上则行不通,因为一次只能运行一个站点。 要启动第二个站点,您首先必须停止默认网站。

Edit... upon further investigation I found that if you can set up multiple sites and run them simultaneously. Just need to stop and start the sites after setting the host values to get them to both run at the same time.

Original post:

The straight-forward way to do this would be to add another application by opening IIS and right-clicking Sites then select Add Web Site. In there you can specify the physical path of Application2 and also set the "host" to "www.example.net" which will filter all those requests to your second site. Any requests that don't match "www.example.net" will still go to the default web site.

That approach will work fine on Windows Server using IIS, but on Vista's IIS7 it won't work since you can only have one site running at a time. To start the second site, you'd first have to stop Default Web Site.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文