function my_template_redirect(){
if( is_404() && $_SERVER["REQUEST_URI"] != '/404/' ){
header("HTTP/1.0 404 Not Found");
echo "<script type='text/javascript'> document.location.href = 'http://site.ru/404/'; </script>";
exit();
}
}