ErrorDocument Directive
| Description: | What the server will return to the client in case of an error |
|---|---|
| Syntax: | ErrorDocument error-code document |
| Context: | server config, virtual host, directory, .htaccess |
| Override: | FileInfo |
| Status: | Core |
| Module: | core |
| Compatibility: | Quoting syntax for text messages is different in Apache 2.0 |
In the event of a problem or error, Apache can be configured to do one of four things,
- output a simple hardcoded error message
- output a customized message
- redirect to a local URL-path to handle the problem/error
- redirect to an external URL to handle the problem/error
The first option is the default, while options 2-4 are
configured using the ErrorDocument
directive, which is followed by the HTTP response code and a URL
or a message. Apache will sometimes offer additional information
regarding the problem/error.
URLs can begin with a slash (/) for local URLs, or be a full URL which the client can resolve. Alternatively, a message can be provided to be displayed by the browser. Examples:
ErrorDocument 500 http://foo.example.com/cgi-bin/tester
ErrorDocument 404 /cgi-bin/bad_urls.pl
ErrorDocument 401 /subscription_info.html
ErrorDocument 403 "Sorry can't allow you access today"
Additionally, the special value default can be used
to specify Apache's simple hardcoded message. While not required
under normal circumstances, default will restore
Apache's simple hardcoded message for configurations that would
otherwise inherit an existing ErrorDocument.
ErrorDocument 404 /cgi-bin/bad_urls.pl
<Directory /web/docs>
ErrorDocument 404 default
</Directory>
Note that when you specify an ErrorDocument
that points to a remote URL (ie. anything with a method such as
http in front of it), Apache will send a redirect to the
client to tell it where to find the document, even if the
document ends up being on the same server. This has several
implications, the most important being that the client will not
receive the original error status code, but instead will
receive a redirect status code. This in turn can confuse web
robots and other clients which try to determine if a URL is
valid using the status code. In addition, if you use a remote
URL in an ErrorDocument 401, the client will not
know to prompt the user for a password since it will not
receive the 401 status code. Therefore, if you use an
ErrorDocument 401 directive then it must refer to a local
document.
Microsoft Internet Explorer (MSIE) will by default ignore server-generated error messages when they are "too small" and substitute its own "friendly" error messages. The size threshold varies depending on the type of error, but in general, if you make your error document greater than 512 bytes, then MSIE will show the server-generated error rather than masking it. More information is available in Microsoft Knowledge Base article Q294807.
Prior to version 2.0, messages were indicated by prefixing them with a single unmatched double quote character.
See also
출처 : http://httpd.apache.org/docs-2.0/ko/mod/core.html#errordocument
"http://"로 시작하는 외부 URL은 잘 적용되지만 "/"로 시작하는 내부 URL-path는 연결이 되질 않습니다. 왜 그런지 이유를 모르겠습니다.