8

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?

Community
  • 1
  • 1
sergserg
  • 21,716
  • 41
  • 129
  • 182
  • @lazyberezovsky: Thanks for linking that question but none of those answers apply for me. My "subdomains" **are not known** ahead of time, they need to be dynamic and "creatable" so to speak. If you were to register on the site you would have to be able to create `lazyberez.foo.com` without any interaction from me as the owner of the site. – sergserg Oct 21 '12 at 01:34

3 Answers3

9

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

Serge
  • 6,088
  • 17
  • 27
0

I don't know if it is possible in the Windows world to do "url rewrite" link in Apache.

So people would see : www.georgestires.foo.com but it would actually be www.foo.com/georgestires. This way you don't have to create real subdomain for each account.

omanna
  • 31
  • 1
  • 4
0

You need DNAME record pointing to your server and simply configure IIS to accept all request on port 80 and send to your app. Than check hostheader to see what incoming domain is.

Now for SSL you'll need more work. Again *.mydomain certificate may work fine for you.

Alexei Levenkov
  • 98,904
  • 14
  • 127
  • 179
  • Would I need to create a `DNAME` record for every single potential client that creates his store on my website? That doesn't seem do-able. – sergserg Oct 21 '12 at 02:09
  • @Serg, Check the link/[RFC](http://tools.ietf.org/html/rfc2672) - you just need one (better than wildcard CNAME - which only gives you single level). – Alexei Levenkov Oct 21 '12 at 02:32