if (strstr($_SERVER['PHP_SELF'], '.php')):
лишнее AddEventHandler("main","OnEpilog", "ShowError404");
function ShowError404() {
if (CHTTP::GetLastStatus()=='404 Not Found') {
global $APPLICATION;
$APPLICATION->RestartBuffer();
require $_SERVER['DOCUMENT_ROOT'].SITE_TEMPLATE_PATH.'/header1.php';
if(SITE_TEMPLATE_ID === 'en') {
require $_SERVER['DOCUMENT_ROOT'] . 'en/404.php';
} else {
require $_SERVER['DOCUMENT_ROOT'] . '/404.php';
}
require $_SERVER['DOCUMENT_ROOT'].SITE_TEMPLATE_PATH.'/footer.php';
}
}