Multiple domains?

Topics: User Forum
Sep 6, 2007 at 12:37 PM
Hi Cristian,
First of all; I really like your CMS implementation. It's truly powerful and extendable.

I'm now playing with a site structure where multiple hostnames will be redirected to different nodes. I.e. www.domain1.com -> ItemId = 1, www.domain2.com -> ItemId = 2 etc. I've searched through some of the source code but haven't found an example of such implementation. I can see that its possible, but what's the best way to do it?

It would be really nice if you could point me in the right direction through an example or short explanation.

Regards
/Staffan
Coordinator
Sep 6, 2007 at 6:07 PM
This is the way it works in the current version:

Configure these components before the defualt configuration in web.config:
<castle>
...
    <components>
    	<component id="n2.sitesProvider" service="N2.Web.ISitesProvider, N2" type="N2.Web.DynamicSitesProvider, N2" />
    	<component id="n2.urlParser.multipleSite" service="N2.Web.IUrlParser, N2" type="N2.Web.MultipleHostsUrlParser, N2" />
    </components>
 
    <!-- Default configuration -->
...
</castle>
 

Then have your start pages implement N2.Web.ISitesSource:
public class StartPage : N2.ContentItem, ISitesSource
{
	public IEnumerable<Site> GetSites()
	{
		yield return new Site(Parent.ID, ID, "domain1.com");
		yield return new Site(Parent.ID, ID, "www.domain1.com");
	}
}

Regards,
Cristian