AddEventHandler("main", "OnEpilog", "My404PageInSiteStyle"); AddEventHandler("main", "OnEndBufferContent", "deleteKernelCss"); function My404PageInSiteStyle() { if(defined('ERROR_404') && ERROR_404 == 'Y') { global $APPLICATION; $APPLICATION->RestartBuffer(); include $_SERVER['DOCUMENT_ROOT'].SITE_TEMPLATE_PATH.'/header.php'; include $_SERVER['DOCUMENT_ROOT'].'/404.php'; include $_SERVER['DOCUMENT_ROOT'].SITE_TEMPLATE_PATH.'/footer.php'; } } function deleteKernelCss(&$content) { global $USER, $APPLICATION; if((is_object($USER) && $USER->IsAuthorized()) || strpos($APPLICATION->GetCurDir(), "/bitrix/")!==false) return; if($APPLICATION->GetProperty("save_kernel") == "Y") return; $arPatternsToRemove = Array( '/
  • ]+>/', '/
  • ]+>/', '/
  • ]+>/', '/
  • ]+>/', ); $content = preg_replace($arPatternsToRemove, "", $content); $content = preg_replace("/\n{2,}/", "\n\n", $content); return $content; }