0

i have hosted my site as www.sample.com but i need

  • -user1.sample.com
  • -user2.sample.com
  • -user3.sample.com

Is It Possible? every User as SubDomain Name.

Dineshkumar D
  • 13
  • 1
  • 8

1 Answers1

1

You don't actually "create" new subdomains - instead you set-up "wildcard" entries that serve as catch-alls for all unresolved names:

  1. You need a wildcard DNS record so that all subdomains resolve to the same host (IP) address. Not all DNS providers offer this service, so you may need to switch DNS service provides if necessary.
  2. You then need to configure your web-server to handle these requests. You have two options:
    1. Use an endpoint binding (so your IIS website will handle all requests to a given IP address and port-number). Until IIS 10.0 this was the only way to support wildcard, or arbitrary, subdomains. This approach requires a separate IP address for each website.
    2. Use a proper Wildcard Domain binding. (IIS finally added support for this feature in version 10.0)[0] (IIS 10.0 was released with Windows 10 and Windows Server 2016). This is not supported in IIS 8.5 or earlier.
  3. Your application code needs to inspect the HTTP Host: header to determine what was inspected. If you're using ASP.NET with Routing (which ASP.NET MVC does automatically) you can use a custom RouteBase subclass to let you use Host header values in routes, as per this example: http://benjii.me/2015/02/subdomain-routing-in-asp-net-mvc/

Note that both options for Step 2 require customer server configuration options (either an IP-address binding, or to be running Windows Server 2016). If you're using a Shared-hosting provider (HostGator, DreamHost, etc - even Azure Websites) then this will not be available to you as they typically don't offer those to their customers - but ask them anyway to see if they can support you.

Dai
  • 141,631
  • 28
  • 261
  • 374