Forum Moderators: phranque
ErrorDocument 400 /errors/badrequest.html
ErrorDocument 401 /errors/authreqd.html
ErrorDocument 403 /errors/forbid.html
ErrorDocument 404 /errors/notfound.html
ErrorDocument 500 /errors/serverr.html
Could I write
ErrorDocument (variable) /errors/error.php?(variable)
Are variables even possible in .htaccess? If so, this would make custom error documents a lot easier.
You *can* append a fixed query string to the ErrorDocument URL-path, if that helps. And you can also rewrite ErrorDocument URL-path requests using mod_rewrite, which also might help.
It really depends on what overall goal you're trying to get to, and why.
Based on the example you posted, I want to add that I think it is a very dangerous thing to point 500-Server Error handling to a script. If you get a 500-Server Error, that's a potentially-very-serious problem. Handling it should invoke the absolute bare minimum of dependencies.
I recommend handling 500-Server Errors with completely-static html pages with no images or includes of any kind. Otherwise, if you have say, an error in one of your common content-handling or authorization scripts, you face the possibility of that one 'small' error causing a catastrophic cascade of events that brings your entire server down. In other words, if you get a 500-Server Error while trying to process a 500-Server Error, and that in turn generates another and another and another... because a common script has an obscure bug in it or an image has been moved or misnamed, that's very bad news.
Jim
It really depends on what overall goal you're trying to get to, and why.
However, you could point all error handlers to one script, and have the script sort out what to do based on existing server and HTTP_REQUEST variables. You *can* append a fixed query string to the ErrorDocument URL-path, if that helps. And you can also rewrite ErrorDocument URL-path requests using mod_rewrite, which also might help.
Since this is becoming a PHP question, I'd suggest asking about it in our PHP forum, with the basic premise of an ErrorDocument definition like:
ErrorDocument 400 /error.php?error_code=400
ErrorDocument 401 /error.php?error_code=401
ErrorDocument 403 /error.php?error_code=403
ErrorDocument 404 /error.php?error_code=404
ErrorDocument 410 /error.php?error_code=410