g1smd - 8:21 am on Mar 20, 2012 (gmt 0) [edited by: g1smd at 8:23 am (utc) on Mar 20, 2012]
The 302 is returned because the ErrorDocument should point only to an internal path and filename not to a full URL with protocol and domain name.
The Apache manual page for the ErrorDocument directive specifically warns that including a domain name will generate an unwanted 302 response.
Adding the PHP code above will generate 404 instead of 200 when the 404 file is directly requested but won't help with the 302 problem when it is invoked as a server error message.
[edited by: g1smd at 8:23 am (utc) on Mar 20, 2012]