How to create subdomains for IIS7 programmatically?

后端 未结 2 512
清酒与你
清酒与你 2021-02-06 03:59

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, e

2条回答
  •  不要未来只要你来
    2021-02-06 04:26

    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.

    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

提交回复
热议问题