Host Header based site collections

This post is all about being able to host multiple domains in one web application and separated on a site collection level. And all this without touching the IIS configuration in IIS Manager.

A colleague of mine told me today about the -hhurl parameter for the stsadm -o createsite command. Again until today, …never heard of it, but man is it great! [;)]

Let me explain with an example:

I create a web application on my testserver with a url of http://hosting.mydomain.com. So if I go into Central Admin now, I can only see one web application with this url. If I want to create a site collection in this web application with a url http://www.myotherdomain.com, then I can create this site collection with the following command:

stsadm -o createsite -url http://www.myotherdomain.com -owneremail [email protected] -ownerlogin Mydomain\myuser -hhurl http://hosting.mydomain.com/myotherdomain

Assuming that I have created the necessary DNS records for www.myotherdomain.com, pointing to my WSS (and even MOSS) server, I can navigate to this URL and find my new site collection asking me to pick a site template because I did not specify it in my createsite command.

If now, I go into Central Administration and list the site collections for the web application hosting.mydomain.com, I can see an entry with the name www.myotherdomain.com

As curious as I am, I went into IIS manager to find some trace of this new domain in the hostheader settings and I was surprised not to find anyrthing there. So how is IIS able to cope with this? Probably the SharePoint API is picking any requests for this domain up and returning the SharePoint site.

So I went a little further on this and experimented a little with IIS:

What if I create a website in IIS with the hostheader www.myotherdomain.com?
The anwer: the IIS website is now returned instead of the SharePoint site…so IIS takes precedence over the SharePoint site?

What if I now stop the IIS website and leave the configuration in IIS of this website?
The answer: the SharePoint website is back !

This makes me see a cool new feature. I can setup a IIS site with for example a Maintenance message explaining that the www.myotherdomain.com website is down for maintenance and simply start this website when i need to do maintenance on the SharePoint site. After the maintenance stop it, and voila.. SharePoint is back.

If you find all this interesting, then I should point you to the Plan for host-named site collections document on Technet

At least I had a lot of fun playing with this. I hope you do to.

2 thoughts on “Host Header based site collections

  1. Hi,

    I tried to follow the steps you have mentioned, however, even though the site collection was created, when i tried to access it, i get a IIS message saying “Site Under Construction”.

    Please note that my web app is on non-standard port(5555) and i have made a entry into local host file with the ip address of the machine so that i am sure on the DNS entries. However, no luck so far. Can you please help?

    Thanks in advance

  2. Hi,

    sorry for the late reply but anyway. I fyou haven’t found the solution yet, then I would suggest adding the domain that have configured to the IIS site of your web application as an additional host header. Seems to me your IIS is having troubel now to relate the incoming request to the correct site.

    best regards,

    Dirk

Leave a Reply

Your email address will not be published. Required fields are marked *