For those that do not know Composite C1 is an Open Source Content Management System (CMS) written for ASP.NET.
If ever you have wondered how to have one physical representation of your Composite C1 site on your server, but serve multiple Sites then this is how I did it...It might be necessary to use this scenario in order to save you having to add all those useful tweaks and reusable function calls to every installation of Composite you might otherwise need.
Note: I have not catered for secure sites as yet. But this should not be difficult to implement in Code Sample 3. You would just need to interrogate the incoming Url to see if it is https or not then select the correct redirect mode.
You will need to set up string array containing all the domains that will be hosted similar to that in Code Sample 1. NB: Leave off the www. because this may or may not be included when the surfer enters the Url.
Code Sample 1:
|
/// /// The domains that Composite C1 auto navigator is designed to work with. /// public static string[] _Domains = new string[] { "dare-it.com", "ibuyzit.robertsonweb.me.uk" };
|
You will need to set up an enum with the same number of elements as are in the string array from Code Sample 1. Note that the enums must match the names of the root pages for each site, also "-" becomes "_".
Code Sample 2:
Now for the juicy bit. The engine, so to speak, which makes sure the page matches the domain. There are essentially two sections. The first part handles a domain entry point from default.aspx, the second handles a domain entry point from any other page.
Code Sample 3:
Below is a snippet from the default.aspx of the main site. The line in Red is the call to the Redirect function in Code Sample 3. This ensures that regardless of page being called up the correct domain is selected for it and from that point on the correct content is filtered from ALL the content contained within the Composite C1 installation.
Code Sample 4:
Code Sample 5 is taken from the CompositeC1Page.cs in the Core library. The line in Red below is the call to Redirect in Code Sample 3. We do not want to process the rest of the page (hence passing true to Redirect) if a Redirect occurs as it will get reprocessed correctly on the way in again when the correct Url has been selected.
Code Sample 5: