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

Entry

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 208.247.106.187) If the web server 
on 208.247.106.187 is down then it's not possible to redirect someone 
to another server through PHP running on 208.247.106.187 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 207.25.71.20, 207.25.71.22, 207.25.71.23, 
207.25.71.24, 207.25.71.25, 207.25.71.26, 207.25.71.27, 207.25.71.28, 
207.25.71.29, 207.25.71.30, 207.25.71.5, 207.25.71.6 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 
question...
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!
http://www.healthdothealth.com
http://www.healthxhealth.com
http://www.mesotheliomainmesothelioma.com
http://www.healthfirewall.com
http://www.flathealth.com
http://www.healthbodyguard.com