Bennylope I have not tried what you suggested in your last post, but back trying to get my WAMP to run it, to best show you my setup I have collated an image together showing the screenshots of what my subsites setup looks like.
http://www.flickr.com/photos/42659897@N08/4597647580/sizes/l/
WillR said that getting subdomains to resolve are the bulk of peoples troubles with the module and to go through the subsite.php and debug the getSubsiteID function to find out what is going wrong.
I've done my best to try and get some information from the variables to work on what is going on and atempt to do some cross checking but I don't seem to be getting to far with it, all
#Debug::show($host); gives me is subsite1.mysilverstripe
Got any ideas on what or how I should be debugging this to work out what is going on?
/**
* Get a matching subsite for the given host, or for the current HTTP_HOST.
*
* @param $host The host to find the subsite for. If not specified, $_SERVER['HTTP_HOST']
* is used.
*
* @return int Subsite ID
*/
static function getSubsiteIDForDomain($host = null, $returnMainIfNotFound = true) {
if($host == null) $host = $_SERVER['HTTP_HOST'];
$host = str_replace('www.','',$host);
$SQL_host = Convert::raw2sql($host);
$matchingDomains = DataObject::get("SubsiteDomain", "'$SQL_host' LIKE replace(\"SubsiteDomain\".\"Domain\",'*','%')",
"\"IsPrimary\" DESC", "INNER JOIN \"Subsite\" ON \"Subsite\".\"ID\" = \"SubsiteDomain\".\"SubsiteID\" AND
\"Subsite\".\"IsPublic\"=1");
if($matchingDomains) {
$subsiteIDs = array_unique($matchingDomains->column('SubsiteID'));
if(sizeof($subsiteIDs) > 1) user_error("Multiple subsites match '$host'", E_USER_WARNING);
return $subsiteIDs[0];
}
// Check for a 'default' subsite
if ($default = DataObject::get_one('Subsite', "\"DefaultSite\" = 1")) {
return $default->ID;
}
// Default subsite id = 0, the main site
return 0;
Another related function
/**
* This function gets the current subsite ID from the session. It used in the backend so Ajax requests
* use the correct subsite. The frontend handles subsites differently. It calls getSubsiteIDForDomain
* directly from ModelAsController::getNestedController. Only gets Subsite instances which have their
* {@link IsPublic} flag set to TRUE.
*
* You can simulate subsite access without creating virtual hosts by appending ?SubsiteID=<ID> to the request.
*
* @todo Pass $request object from controller so we don't have to rely on $_REQUEST
*
* @param boolean $cache
* @return int ID of the current subsite instance
*/
static function currentSubsiteID() {
if(isset($_REQUEST['SubsiteID'])) $id = (int)$_REQUEST['SubsiteID'];
else $id = Session::get('SubsiteID');
if($id === NULL) {
$id = self::getSubsiteIDForDomain();
Session::set('SubsiteID', $id);
}
return (int)$id;
}
Did you try doing this at all???