faqts : Computers : Programming : Languages : PHP

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

20 of 30 people (67%) answered Yes
Recently 8 of 10 people (80%) answered Yes


How can I generate redirect to other html page from PHP page when the PHP server is down?

Nov 27th, 2008 05:01
healthy man, dman, Jonathan Sharp, tom lin, http://www.ttnr.org

When a request is made for your server, an IP address is returned. (For 
example www.php.net's IP address is If the web server 
on is down then it's not possible to redirect someone 
to another server through PHP running on as it can't 
answer requests! 
Fail over can be accomplished through DNS (Domain Name System) which 
translates domain names to IPs. If you have multiple servers, it's 
possible to enter multiple IP addresses for one domain name. (For 
example, cnn.com has,,,,,,,,,,, listed as it's 
IPs!) If you're running a high volume site, it's possible to do more 
advanced fail over with load balancing and and redundant nics which 
will start up if one dies, but that's out of the scope of this 
So, the short answer: No, it's not possible to have PHP redirect users 
to another site if the server which your site is running on goes down.
There is an exception to this. Say you have 3 servers, A, B & C. 
www.yourdomain.com is being run on server A. Server B & C contain the 
same content. When someone types in www.yourdomain.com the request goes 
to server A where PHP is running. Server A then checks if server B is 
up by possibly seeing if it can succeed with a socket(); connect(); If 
so it will print a &lgt;meta http-equiv="Refresh" content="0; 
URL=www.serverb.com"&rgt; otherwise it would try and do a socket(); 
connect(); to server C to see if that was up. But again, this is 
dependent that server A always stays up!