Por si a alguien le pudiera venir bien, dejo por aquí la función con la que he resuelto el problema:
Código PHP:
define ('PRIMARY_SERVER', 'server1.es.empresa.com'); # Servidor primario
define ('SECONDARY_SERVER', 'server2.es.empresa.com'); # Servidor secundario
function chooseServer() {
$server1_is_up = @fsockopen(PRIMARY_SERVER, 80);
if (!server1_is_up) {
$server2_is_up = @fsockopen(SECONDARY_SERVER, 80);
if (!$server2_is_up) {
echo 'Los servidores primario y secundario están caídos';
} else {
header('Location: ' .SECONDARY_SERVER. '/ruta_relativa/');
}
} else {
header('Location: ' .PRIMARY_SERVER. '/ruta_relativa/');
}
}
Gracias a xyyy7 por la ayuda ;)