如何为IIS7创建子域编程? [英] How to create subdomains for IIS7 programmatically?

查看:132
本文介绍了如何为IIS7创建子域编程?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写在C#/ ASP.NET一个SaaS应用程序,用IIS7主办。我想创建一个个性化的子域名为每一个签约客户,即fred.mydomain.com,bob.mydomain.com,每个将指向相同的应用程序,只需用每一个客户不同的皮肤。

I'm writing a SaaS app in C#/ASP.NET, hosted with IIS7. I want to create a personalized subdomain for every customer that signs up, i.e. fred.mydomain.com, bob.mydomain.com, each of which will point to the same app, just with a different skin per customer.

如何编程创建这些子域?

How do I create these subdomains programmatically?

推荐答案

使用 URL重写获取IIS7的所有请求映射像 user.mydomain.com (其中用户不是WWW,电子邮件或其他现有实子域)为 mydomain.com/myapp?id=user 然后在你需要的任何主题化脚本处理。

Use URL Rewrite for IIS7 to map all requests like user.mydomain.com (where user is not www, mail or other existing real subdomains) to mydomain.com/myapp?id=user Then in the script handle whatever theming you need.

您不需要添加规则创建的每个用户。只需创建一个一般的规则这样做。

You do not need to add rule for every user created. Just create one general rule to do so.

和同样的,在你的DNS服务器,您需要转发* .mydomain.com来(其中*是不是WWW,电子邮件或其他现有实子域)以mydomain.com IP。这是pretty直线前进。您已经有现有子域的DNS记录。只需添加* .mydomain.com来并指向mydomain.com。这将这样的伎俩的DNS一部分。另一部分则是在 URL重写

And, also, in your server DNS, you need to forward *.mydomain.com (where * is not www, mail or other existing real subdomains) to mydomain.com IP. This is pretty straight forward. You already have DNS records for existing subdomains. Just add *.mydomain.com and point to mydomain.com. This will do the DNS part of the trick. Other part is in the URL Rewrite

这篇关于如何为IIS7创建子域编程?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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