如何在IIS 7上设置子域

时间:2022-09-01 22:08:58

I have a website sitting on an IIS 7 server: WWW.example.COM

我有一个在iis7服务器上的网站:WWW.example.COM。

I would like to create several sub domains that looks like SUBDOMAIN1.example.COM

我想创建几个子域,看起来像SUBDOMAIN1.example.COM

I created an IIS website and I set the bindings to be http, port 80, the ip address of my server, and SUBDOMAIN1.example.COM and the physical path to a folder under example.COM

我创建了一个IIS网站,并将绑定设置为http、端口80、服务器的ip地址和SUBDOMAIN1.example。COM和example.COM下文件夹的物理路径

I restarted my website and clicked on browse, the browser than opened with the address: http://SUBDOMAIN1.example.COM

我重新启动了我的网站,点击了浏览,浏览器打开了地址:http://SUBDOMAIN1.example.COM

But the website doesn't show up.

但是网站没有出现。

Do I have to do something with the DNS?

我需要对DNS做些什么吗?

5 个解决方案

#1


79  

This one drove me crazy... basically you need two things:

这个让我发疯……基本上你需要两样东西:

1) Make sure your DNS is setup to point to your subdomain. This means to make sure you have an A Record in the DNS for your subdomain and point to the same IP.

1)确保您的DNS设置为指向子域。这意味着要确保在您的子域的DNS中有一个A记录,并指向相同的IP。

2) You must add an additional website in IIS 7 named subdomain.example.com

2)您必须在IIS 7中添加一个名为subdomain.example.com的附加网站

  • Sites > Add Website
  • 网站>添加网站
  • Site Name: subdomain.example.com
  • 网站名称:subdomain.example.com
  • Physical Path: select the subdomain directory
  • 物理路径:选择子域目录
  • Binding: same ip as example.com
  • 绑定:与example.com相同的ip。
  • Host name: subdomain.example.com
  • 主机名:subdomain.example.com

#2


6  

Wildcard method: Add the following entry into your DNS server and change the domain and IP address accordingly.

通配符方法:将以下条目添加到您的DNS服务器,并相应地更改域和IP地址。

*.example.com IN A 1.2.3.4

* .example.com为1.2.3.4

http://www.webmasterworld.com/microsoft_asp_net/3194877.htm

http://www.webmasterworld.com/microsoft_asp_net/3194877.htm

#3


5  

If your computer can't find the IP address associated with SUBDOMAIN1.example.COM, it will not find the site.

如果您的计算机找不到与SUBDOMAIN1.example关联的IP地址。COM,它找不到这个网站。

You need to either change your hosts file (so you can at least test things - this will be a local change, only available to yourself), or update DNS so the name will resolve correctly (so the rest of the world can see it).

您需要更改您的主机文件(这样您至少可以测试一些东西——这将是一个本地更改,只对您自己可用),或者更新DNS,这样名称就可以正确解析(因此,世界其他地方可以看到它)。

#4


0  

As DotNetMensch said but you DO NOT need to add another site in IIS as this can also cause further problems and make things more complicated because you then have a website within a website so the file paths, masterpage paths and web.config paths may need changing. You just need to edit teh bindings of the existing site and add the new subdomain there.

正如DotNetMensch所说,但你不需要在IIS中添加另一个站点,因为这也会导致进一步的问题,使事情变得更加复杂,因为你在一个网站中有一个网站,文件路径、主页路径和web。配置路径可能需要改变。您只需编辑现有站点的teh绑定,并在其中添加新的子域。

So:

所以:

  1. Add sub-domain to DNS records. My host (RackSpace) uses a web portal to do this so you just log in and go to Network->Domains(DNS)->Actions->Create Zone, and enter your subdomain as mysubdomain.domain.com etc, leave the other settings as default

    向DNS记录添加子域。我的主机(RackSpace)使用一个web门户来实现这一点,所以您只需登录并进入Network-> domain (DNS)->Actions->Create Zone,然后输入子域mysubdomain.domain.com等,其他设置保持默认

  2. Go to your domain in IIS, right-click->Edit Bindings->Add, and add your new subdomain leaving everything else the same e.g. mysubdomain.domain.com

    转到IIS中的域,右键单击->编辑绑定->添加,然后添加新的子域,使其他所有内容保持不变,例如mysubdomain.domain.com

You may need to wait 5-10 mins for the DNS records to update but that's all you need.

你可能需要等待5-10分钟才能更新DNS记录,但这就是你所需要的。

#5


-1  

You could use apache server, it checks the URL for the sub-domain so you just need the DNS set up to the main website.

您可以使用apache服务器,它检查子域的URL,因此您只需要将DNS设置为主站点。

#1


79  

This one drove me crazy... basically you need two things:

这个让我发疯……基本上你需要两样东西:

1) Make sure your DNS is setup to point to your subdomain. This means to make sure you have an A Record in the DNS for your subdomain and point to the same IP.

1)确保您的DNS设置为指向子域。这意味着要确保在您的子域的DNS中有一个A记录,并指向相同的IP。

2) You must add an additional website in IIS 7 named subdomain.example.com

2)您必须在IIS 7中添加一个名为subdomain.example.com的附加网站

  • Sites > Add Website
  • 网站>添加网站
  • Site Name: subdomain.example.com
  • 网站名称:subdomain.example.com
  • Physical Path: select the subdomain directory
  • 物理路径:选择子域目录
  • Binding: same ip as example.com
  • 绑定:与example.com相同的ip。
  • Host name: subdomain.example.com
  • 主机名:subdomain.example.com

#2


6  

Wildcard method: Add the following entry into your DNS server and change the domain and IP address accordingly.

通配符方法:将以下条目添加到您的DNS服务器,并相应地更改域和IP地址。

*.example.com IN A 1.2.3.4

* .example.com为1.2.3.4

http://www.webmasterworld.com/microsoft_asp_net/3194877.htm

http://www.webmasterworld.com/microsoft_asp_net/3194877.htm

#3


5  

If your computer can't find the IP address associated with SUBDOMAIN1.example.COM, it will not find the site.

如果您的计算机找不到与SUBDOMAIN1.example关联的IP地址。COM,它找不到这个网站。

You need to either change your hosts file (so you can at least test things - this will be a local change, only available to yourself), or update DNS so the name will resolve correctly (so the rest of the world can see it).

您需要更改您的主机文件(这样您至少可以测试一些东西——这将是一个本地更改,只对您自己可用),或者更新DNS,这样名称就可以正确解析(因此,世界其他地方可以看到它)。

#4


0  

As DotNetMensch said but you DO NOT need to add another site in IIS as this can also cause further problems and make things more complicated because you then have a website within a website so the file paths, masterpage paths and web.config paths may need changing. You just need to edit teh bindings of the existing site and add the new subdomain there.

正如DotNetMensch所说,但你不需要在IIS中添加另一个站点,因为这也会导致进一步的问题,使事情变得更加复杂,因为你在一个网站中有一个网站,文件路径、主页路径和web。配置路径可能需要改变。您只需编辑现有站点的teh绑定,并在其中添加新的子域。

So:

所以:

  1. Add sub-domain to DNS records. My host (RackSpace) uses a web portal to do this so you just log in and go to Network->Domains(DNS)->Actions->Create Zone, and enter your subdomain as mysubdomain.domain.com etc, leave the other settings as default

    向DNS记录添加子域。我的主机(RackSpace)使用一个web门户来实现这一点,所以您只需登录并进入Network-> domain (DNS)->Actions->Create Zone,然后输入子域mysubdomain.domain.com等,其他设置保持默认

  2. Go to your domain in IIS, right-click->Edit Bindings->Add, and add your new subdomain leaving everything else the same e.g. mysubdomain.domain.com

    转到IIS中的域,右键单击->编辑绑定->添加,然后添加新的子域,使其他所有内容保持不变,例如mysubdomain.domain.com

You may need to wait 5-10 mins for the DNS records to update but that's all you need.

你可能需要等待5-10分钟才能更新DNS记录,但这就是你所需要的。

#5


-1  

You could use apache server, it checks the URL for the sub-domain so you just need the DNS set up to the main website.

您可以使用apache服务器,它检查子域的URL,因此您只需要将DNS设置为主站点。