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 22.214.171.124) If the web server
on 126.96.36.199 is down then it's not possible to redirect someone
to another server through PHP running on 188.8.131.52 as it can't
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 184.108.40.206, 220.127.116.11, 18.104.22.168,
22.214.171.124, 126.96.36.199, 188.8.131.52, 184.108.40.206, 220.127.116.11,
18.104.22.168, 22.214.171.124, 126.96.36.199, 188.8.131.52 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!