AddEventHandler("main", "OnUserLogout", "debugLogout"); function debugLogout() { global $USER, $APPLICATION; if($APPLICATION->GetCurDir() != SITE_DIR){ LocalRedirect("/?logout=yes"); } }