1

any ideas how to replace Apache HTTP 500 (Internal Server Error) error by HTTP 503 (Service Unavailable) on PHP error once PHP error displaying is off? This is much better option to inform spiders to back to the site soon...

P.S. would be great to be able to append Retry-After to the 50x error codes if possible...

cheers, /Marcin

2 Answers 2

2

I assume you are referring to PHP's new (since 5.2.4) default behaviour of throwing a 500 if an error occurs, and no other output is being made.

AFAIK, that behaviour is hard-coded, you won't be able to change that without changing PHP itself.

The easiest way may be setting up a custom error handler, and having that throw a 503 for you:

header("HTTP/1.1 503 Service Unavailable");
echo "--- error message here -----";
die();
Sign up to request clarification or add additional context in comments.

2 Comments

but in that case I mustn't have error_reporting(0); - errors must be enabled right ?
@Marcin no, it can be any value. Your error handler will be called in any case.
0

I wonder if you could do something like an Apache

Redirect 503 /error/500 /maintenance.html 

on an

ErrorDocument 500 /error/500 

directive?

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.