homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

Please Help!

5+ Year Member

Msg#: 4047157 posted 7:33 pm on Dec 21, 2009 (gmt 0)

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]



5+ Year Member

Msg#: 4047157 posted 9:10 pm on Dec 23, 2009 (gmt 0)

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.


5+ Year Member

Msg#: 4047157 posted 10:15 pm on Dec 23, 2009 (gmt 0)

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.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved