Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Please Help!



7:33 pm on Dec 21, 2009 (gmt 0)

5+ Year Member

can u make me PHP script if SERVER A Goes down this PHP Page check the status & than Redirect user to SERVER B....

thing is that i made IIS 7 Server on my PC & some time i turn off my PC ill upload this PHP file on free hosting my domain name.

when some1 open page this PHP page loads itself & check if My PC is on than it should show my IIS 7 Pages if not than it will redirect to this page Sorry the Server is dowN

i have DNS Service for my IIS 7 all i need is pHP script who check this status & do this function

[edited by: eelixduppy at 7:45 pm (utc) on Dec. 21, 2009]
[edit reason] removed specifies [/edit]


9:10 pm on Dec 23, 2009 (gmt 0)

5+ Year Member

Instead of sing PHP and redirects, why not create an IP failover? This would be much simpler, more effective, and is likely to save a #*$! load of headaches.


10:15 pm on Dec 23, 2009 (gmt 0)

5+ Year Member

I'm not sure I would do this purely via PHP either.... But if you are determined; say your home PC is www.homepc.com and your offsite hosting is www.somehost.com:

On the somehost.com, you would need a page like the following:

$request = $_SERVER['REQUEST_URI'];
$homeURL = "http://www.homepc.com{$request}";
$contents = file_get_contents("$homeURL");
if ($contents===false)
/*do nothing or add code as needed. at this stage, it means the home site is unavailable. so you could have content below this code or you could redirect to other content, etc.*/
/*Basically content can now be retrieved from your home PC. You can either redirect the user to your home PC server with PHP header calls, ie:*/
header("Location: {$homeURL}");
/*Or you could even "print out" the retrieved contents, ie:*/
echo $contents;

To be honest, I have not tried this and am not sure if the get_file_contents() function will handle as I anticipate because I have never done anything like this with PHP. But I presume that if you request the file off your home PC, and it is not available (file contents cannot be retrieved), then the function should output boolean false. If you get this as output, you know the home PC is down. But if you do content back, you'll know the home PC is up and running so you can either redirect the user or even use coding to pull content off the home PC and display it directly to the user on the hosted site.


Featured Threads

Hot Threads This Week

Hot Threads This Month