ENHANCEMENT: Make base tag in 404 page dynamic (from r72282)

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@88633 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sam Minnee 2009-10-12 03:23:10 +00:00
parent c347278dda
commit cad7d5e859
2 changed files with 7 additions and 1 deletions

View File

@ -127,12 +127,15 @@ class ErrorPage extends Page {
$response = Director::test(Director::makeRelative($this->Link()));
$errorContent = $response->getBody();
// Make the base tag dynamic.
$errorContent = preg_replace('/<base[^>]+href="' . str_replace('/','\\/', Director::absoluteBaseURL()) . '"[^>]*>/i', '<base href="$BaseURL" />', $errorContent);
// Check we have an assets base directory, creating if it we don't
if(!file_exists(ASSETS_PATH)) {
mkdir(ASSETS_PATH, 02775);
}
// if the page is published in a language other than default language,
// write a specific language version of the HTML page
$filePath = self::get_filepath_for_errorcode($this->ErrorCode, $this->Locale);

View File

@ -324,7 +324,10 @@ class Debug {
} else {
$errorFilePath = ErrorPage::get_filepath_for_errorcode($statusCode, Translatable::get_current_locale());
if(file_exists($errorFilePath)) {
echo file_get_contents($errorFilePath);
$content = file_get_contents(ASSETS_PATH . "/error-$statusCode.html");
// $BaseURL is left dynamic in error-###.html, so that multi-domain sites don't get broken
echo str_replace('$BaseURL', Director::absoluteBaseURL(), $content);
} else {
$renderer = new DebugView();
$renderer->writeHeader();