Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to allow users to create their own subdomains on my MVC website? [duplicate]

Possible Duplicate:
Is it possible to make an ASP.NET MVC route based on a subdomain?

I'm going to build a website that will allow users to create their own virtual store, hosted by my website.

Think eBay; letting small businesses create their stores.

For example:

www.foo.com                 - The main website.
www.georgestires.foo.com    - "George's Tires" online store.

I would let the users create their own stylesheets and customizations to an extent, but that's for later. Right now I'm wondering about how to implement this feature on an MVC 3 website.

I'm literally at ground zero here with no legs to stand on. Any and all advice is appreciated. I know that in IIS I can create a "bar.foo.com" subdomain binding and have that direct flow to my ASP.Net MVC3 application, but does that mean that every time someone creates their store I will have to programatically create a new binding?

Is that even possible? Should I be looking at that approach?

like image 417
sergserg Avatar asked Oct 21 '12 01:10

sergserg


1 Answers

The bind DNS server and Microsoft DNS server both allow to setup a wildcard entry that match any nonexisting entry in the domain:

*.example.com.   3600 IN  CNAME host1.example.com.

Then you setup an URL rewrite rule in the IIS that turns the URL of the form http://subdomain.yourdomain.com/ into, say, http://yourdomain.com/?root=subdomain

This will allow you to manage these cloned sites using a database.

The only drawback is that DNS system does not allow you to setup a wildcard entry of the form www.*.yourdomain.tld

like image 186
Serge Avatar answered Sep 27 '22 19:09

Serge