1

I want to create many virtual subdomains e.g my original site is www.Test.com but I want that my site users can open my site with the given pattern username.Test.com

Can you please help me for this issue?

1 Answers1

2

There will be a couple of things that you need to do in this situation. First, you will need to create a wildcard DNS entry. Most DNS server software will allow you to create an A record called * which you can direct to the IP address of your web server. This will cause the DNS server to resolve anything.example.com to the IP address specified. If you have other hostnames, such as www.example.com specifically defined, those records will override the wildcard (i.e. the wildcard will not negate your existing records or any other record specifically defined).

Second, you will need to configure your web server (I'll presume IIS since you tagged the question with asp.net) with a binding to the same IP address specified in the DNS record. Do not specify a hostname on this binding. This will cause IIS to catch any request for that IP address which isn't specifically bound to another website entry by its IP/name combination (again, you can have a site bound to the same IP with specific hostnames which will override this one).

Next, in your application code, you will need to handle the incoming request by looking at the variables coming from the server, specifically the SERVER_NAME or HTTP_HOST server variables as they will contain the hostname the user is attempting to access. The code would then reference this hostname back to a user's account and serve up the appropriate content for the hostname in question.

Justin Scott
  • 8,798
  • 1
  • 28
  • 39