Script that forwards you to a secondary server if main server is offline

chougard

In Runtime
Messages
148
Is there a script that I can use that would check if fye.x10hosting.com is up and if it is down send connections to fyebackup.freehostia.com? My members keep telling me my site is down. I'd like to send them to a little page on a different server that tells them the server is down and not to tell me. So all I need is the script that checks the status. It would be on a server that has low downtime. Thanks for any help!

I was given the following by Torch on the x10hosting forums.

Code:
<?
error_reporting(0); // Disables error reporting
$URI = "google.com"; // Your main server address, can be IP too (DON'T PUT http://)
$URI2 = "x10hosting.com"; // Your second server address
$TO = 5; // Timeout in seconds
if(fsockopen($URI,80,$TO)){
   header("Location: http://$URI"); // Redirects to your server if it works
   //echo "Server is working perfectly!";
}
else{
   header("Location: http://$URI2"); // Redirects to your second server in case first one doesn't work
   //echo "We are currently having some troubles with the server, please come back later!";
}
?>

So I adjusted it to this:

Code:
<?
error_reporting(0); // Disables error reporting
$URI = "fye.x10hosting.com"; // Your main server address, can be IP too (DON'T PUT http://)
$URI2 = "64.72.112.14"; // Your second server address
$TO = 5; // Timeout in seconds
if(fsockopen($URI,80,$TO)){
   header("Location: http://$URI"); // Redirects to your server if it works
   //echo "Server is working perfectly!";
}
else{
   //header("Location: http://$URI2"); // Redirects to your second server in case first one doesn't work
   echo "We are currently having some troubles with the server, please come back later!";
}
?>

I get a connection was reset error in firefox if the main server is offline.
The file is located here: http://h1.ripway.com/chougard/index.php
 
it work when the server is online. When the server is offline it should display We are currently having some troubles with the server, please come back later!
 
? How is that possible?
Before loading page (with that "offline redirect script) - server must be online where that page is, but if sever is offline, how is it going to load that script?

That doesn't make any sense
 
Athlon is right. That doesn't really make sense. If that script is on a different server, how is the users browser supposed to load it without knowing the server address?
 
My two domains, foryourentertainment.tk and fye.uni.cc will forward people to that script if and when it works. Right now they forward connections to fye.x10hosting.com
 
Back
Top Bottom