BUGFIX: Set absolute domain of 'main site' properly. (from r80951)

This commit is contained in:
Tom Rix 2010-03-01 02:53:15 +00:00
parent 503ec12dd8
commit e83287fd2d
2 changed files with 8 additions and 1 deletions

View File

@ -224,7 +224,10 @@ class SiteTreeSubsites extends DataObjectDecorator {
// Generate the existing absolute URL and replace the domain with the subsite domain.
// This helps deal with Link() returning an absolute URL.
$url = Director::absoluteURL($this->owner->Link());
return preg_replace('/\/\/[^\/]+\//', '//' . $this->owner->Subsite()->domain() . '/', $url);
if($this->owner->SubsiteID) {
$url = preg_replace('/\/\/[^\/]+\//', '//' . $this->owner->Subsite()->domain() . '/', $url);
}
return $url;
}
}

View File

@ -114,6 +114,10 @@ class Subsite extends DataObject implements PermissionProvider {
$domain = str_replace('.www.','.', $domain);
return $domain;
}
// SubsiteID = 0 is often used to refer to the main site, just return $_SERVER['HTTP_HOST']
} else {
return $_SERVER['HTTP_HOST'];
}
}