You can use PHP internal functions like memory-get-usage http://php.net/manual/de/function.memory-get-usage.php or access the Script shell, which gives you some information about the current load to the server. And then, depending on this information, set the redirection through the headers.
However, remember that if your server crashes, most likely PHP Script will not be executed and redirection will not occur. Thus, depending on your infrastructure, you can handle this through an additional server (possibly load balancing).
If you can narrow down the most likely cause of the failure, try to find it there, for example, if your connection to MySQL fails, extract it and direct the user to your "loaded page".
source
share