简体   繁体   English

PHP 捕获(异常 $e)重定向到标头(“位置:

[英]PHP catch (Exception $e) redirect to header("Location:

Production server Debian Apach2.4 behind nginx, requires Java which (very rarely) gets an OOM failure (corrected by cron 1 minute "if no service, restart".)生产服务器 Debian Apache2.4 在 nginx 后面,需要 Java (很少)出现 OOM 故障(由 cron 纠正)1 分钟“没有服务重新启动”

I'm looking to send a 503 page (curls perfectly).我正在寻找发送 503 页面(完美卷曲)。 Following code fails (blank screen):以下代码失败(空白屏幕):

    catch (Exception $e)
    {
    /* redirect to browser */
    header("Location: https://example.com/error/503.html"); 
    die;
    }

Assistance would be greatly appreciated.协助将不胜感激。 Thanks谢谢

Yes, there is a try :是的,有一个try

try {
    $results = $solr->search($query, 0, 30, $params);
    return $results;
}

And no, no shell_exec() I might add that during sandbox development we had:不,没有shell_exec()我可能会补充说,在沙盒开发过程中,我们有:

die("<html><head><title>SEARCH EXCEPTION</title><body><pre>{$e->__toString()}</pre></body></html>");

But obviously do not want that in production.但显然不希望在生产中这样做。 I suppose that I could rewrite the die("<html> line with a "full 503" webpage, but was looking for a more elegant solution.我想我可以用“完整的 503”网页重写die("<html>行,但正在寻找一个更优雅的解决方案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM