Go Back   Computer Forums > Web Design | Website Development > Web Programming
Click Here to Login
Join Computer forums Today


Reply
 
Thread Tools Search this Thread Display Modes
 
Old 11-27-2006, 02:35 AM   #1
In Runtime
 
Join Date: May 2006
Posts: 148
Default Script that forwards you to a secondary server if main server is offline

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
__________________

chougard is offline   Reply With Quote
Old 12-04-2006, 12:32 PM   #2
j03
~~~~~~~~
 
Join Date: Jan 2005
Location: Wales
Posts: 5,556
Send a message via MSN to j03
Default Re: Script that forwards you to a secondary server if main server is offline

Works fine for me! I get taken to http://fye.x10hosting.com/home/ Its a bit slow, though
__________________

j03 is offline   Reply With Quote
Old 12-04-2006, 05:37 PM   #3
In Runtime
 
Join Date: May 2006
Posts: 148
Default Re: Script that forwards you to a secondary server if main server is offline

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!
chougard is offline   Reply With Quote
Old 12-04-2006, 08:09 PM   #4
Baseband Member
 
Join Date: Nov 2006
Posts: 21
Default Re: Script that forwards you to a secondary server if main server is offline

? 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
Athlon95 is offline   Reply With Quote
Old 12-04-2006, 10:33 PM   #5
In Runtime
 
Join Date: May 2006
Posts: 148
Default Re: Script that forwards you to a secondary server if main server is offline

The script is on a different server.
chougard is offline   Reply With Quote
Old 12-05-2006, 12:33 AM   #6
Baseband Member
 
Join Date: Jul 2006
Posts: 53
Default Re: Script that forwards you to a secondary server if main server is offline

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?
falcon1 is offline   Reply With Quote
Old 12-05-2006, 09:03 AM   #7
In Runtime
 
Join Date: May 2006
Posts: 148
Default Re: Script that forwards you to a secondary server if main server is offline

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
__________________

chougard is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



All times are GMT -5. The time now is 06:01 AM.


Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0