blob: 1b08e053ffbb2a1dfbc8c04984d3c9468c544c60 [file] [log] [blame]
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="ja" xml:lang="ja"><head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
<!--
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
This file is generated from xml source: DO NOT EDIT
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
-->
<title>カスタムエラーレスポンス - Apache HTTP サーバ バージョン 2.5</title>
<link href="./style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
<link href="./style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
<link href="./style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="./style/css/prettify.css" />
<script src="./style/scripts/prettify.min.js" type="text/javascript">
</script>
<link href="./images/favicon.ico" rel="shortcut icon" /></head>
<body id="manual-page"><div id="page-header">
<p class="menu"><a href="./mod/">モジュール</a> | <a href="./mod/quickreference.html">ディレクティブ</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="./glossary.html">用語</a> | <a href="./sitemap.html">サイトマップ</a></p>
<p class="apache">Apache HTTP サーバ バージョン 2.5</p>
<img alt="" src="./images/feather.png" /></div>
<div class="up"><a href="./"><img title="&lt;-" alt="&lt;-" src="./images/left.gif" /></a></div>
<div id="path">
<a href="http://www.apache.org/">Apache</a> &gt; <a href="http://httpd.apache.org/">HTTP サーバ</a> &gt; <a href="http://httpd.apache.org/docs/">ドキュメンテーション</a> &gt; <a href="./">バージョン 2.5</a></div><div id="page-content"><div id="preamble"><h1>カスタムエラーレスポンス</h1>
<div class="toplang">
<p><span>翻訳済み言語: </span><a href="./en/custom-error.html" hreflang="en" rel="alternate" title="English">&nbsp;en&nbsp;</a> |
<a href="./es/custom-error.html" hreflang="es" rel="alternate" title="Español">&nbsp;es&nbsp;</a> |
<a href="./fr/custom-error.html" hreflang="fr" rel="alternate" title="Français">&nbsp;fr&nbsp;</a> |
<a href="./ja/custom-error.html" title="Japanese">&nbsp;ja&nbsp;</a> |
<a href="./ko/custom-error.html" hreflang="ko" rel="alternate" title="Korean">&nbsp;ko&nbsp;</a> |
<a href="./tr/custom-error.html" hreflang="tr" rel="alternate" title="Türkçe">&nbsp;tr&nbsp;</a></p>
</div>
<div class="outofdate">この日本語訳はすでに古くなっている
可能性があります。
最近更新された内容を見るには英語版をご覧下さい。
</div>
<p>ウェブマスターが何らかのエラーや問題に対する
Apache の反応を設定できるようにする追加機能を提供します。</p>
<p>サーバがエラーや問題を発見した場合の反応を、
カスタマイズして定義することができます。</p>
<p>スクリプトの実行が失敗して "500 Server Error"
を発生させたとします。この場合の反応を、より好ましいテキストや、別の
URL (内部及び外部) へのリダイレクションに置き換えることができます。
</p>
</div>
<div id="quickview"><ul id="toc"><li><img alt="" src="./images/down.gif" /> <a href="#behavior">動作</a></li>
<li><img alt="" src="./images/down.gif" /> <a href="#configuration">設定</a></li>
<li><img alt="" src="./images/down.gif" /> <a href="#custom">カスタムエラーレスポンスとリダイレクト</a></li>
</ul><h3>参照</h3><ul class="seealso"><li><a href="#comments_section">コメント</a></li></ul></div>
<div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
<div class="section">
<h2><a name="behavior" id="behavior">動作</a></h2>
<h3>古い動作</h3>
<p>NCSA httpd 1.3 は、古くて退屈なエラー/問題メッセージを
返していました。それはしばしばユーザには無意味であり、
またそれを発生させた原因を記録する方法も提供していませんでした。</p>
<h3>新しい動作</h3>
<ol>
<li>NCSA のハードコードされたメッセージの代わりに
他のテキストを表示</li>
<li>ローカルの URL にリダイレクト</li>
<li>外部の URL にリダイレクト</li>
</ol>
<p>するようにサーバを設定できます。</p>
<p>別の URL にリダイレクトすることは役に立ちますが、
それは説明をしたり、より明確に誤り/問題を記録したりするために
何か情報を伝えられるときに限ります。</p>
<p>これを実現するために、 Apache は新しく CGI のような環境変数を
定義します:</p>
<div class="example"><p><code>
REDIRECT_HTTP_ACCEPT=*/*, image/gif,
image/x-xbitmap, image/jpeg<br />
REDIRECT_HTTP_USER_AGENT=Mozilla/1.1b2 (X11; I; HP-UX
A.09.05 9000/712)<br />
REDIRECT_PATH=.:/bin:/usr/local/bin:/etc<br />
REDIRECT_QUERY_STRING=<br />
REDIRECT_REMOTE_ADDR=121.345.78.123<br />
REDIRECT_REMOTE_HOST=ooh.ahhh.com<br />
REDIRECT_SERVER_NAME=crash.bang.edu<br />
REDIRECT_SERVER_PORT=80<br />
REDIRECT_SERVER_SOFTWARE=Apache/0.8.15<br />
REDIRECT_URL=/cgi-bin/buggy.pl
</code></p></div>
<p>頭に付く <code>REDIRECT_</code> に注目してください。</p>
<p>少なくとも <code>REDIRECT_URL</code>
<code>REDIRECT_QUERY_STRING</code> は新しい URL (CGI スクリプトか
CGI インクルードであると仮定されます) に渡されます。
他の変数は、エラーや問題が起きる前に存在した場合にだけ存在します。
もしあなたの設定した <code class="directive"><a href="./mod/core.html#errordocument">ErrorDocument</a></code><em>外部</em>リダイレクト
(<em>すなわち</em><code>http:</code>
のような体系名から始まるすべてのもの。たとえ同じホストを指していても)
ならば、これらは<strong>まったく</strong>設定されません。</p>
</div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
<div class="section">
<h2><a name="configuration" id="configuration">設定</a></h2>
<p><code class="directive"><a href="./mod/core.html#allowoverride">AllowOverride</a></code> が適切に設定されていれば、
.htaccess ファイルで <code class="directive"><a href="./mod/core.html#errordocument">ErrorDocument</a></code>
を使用することができます。</p>
<p>ここに、いくつかの例を挙げます。</p>
<div class="example"><p><code>
ErrorDocument 500 /cgi-bin/crash-recover <br />
ErrorDocument 500 "Sorry, our script crashed. Oh dear" <br />
ErrorDocument 500 http://xxx/ <br />
ErrorDocument 404 /Lame_excuses/not_found.html <br />
ErrorDocument 401 /Subscription/how_to_subscribe.html
</code></p></div>
<p>構文</p>
<div class="example"><p><code>
ErrorDocument &lt;3-digit-code&gt; &lt;action&gt;
</code></p></div>
<p>action (動作) は、下記のいずれかです</p>
<ol>
<li>表示するテキスト。テキストは引用符 (") で囲んで指定します。</li>
<li>リダイレクト先の外部 URL </li>
<li>リダイレクト先のローカル URL </li>
</ol>
</div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
<div class="section">
<h2><a name="custom" id="custom">カスタムエラーレスポンスとリダイレクト</a></h2>
<p>スクリプト/SSI に追加の環境変数が利用可能になるように、
リダイレクトされた URL に対する Apache の動作が変更されました。</p>
<h3>古い動作</h3>
<p>リダイレクトされたスクリプトは標準の CGI
環境変数を利用可能でした。しかし、どこからリダイレクト
されたかの情報は提供されていませんでした。</p>
<h3>新しい動作</h3>
<p>リダイレクトされた先のスクリプトが使用可能なように、
新しいたくさんの環境変数が初期化されます。新しい変数は、それぞれ
<code>REDIRECT_</code> で始まります。
<code>REDIRECT_</code> で始まる環境変数はリダイレクトされる前に存在していた
CGI 環境変数の頭に <code>REDIRECT_</code> を付けて作成されます。
<em>すなわち</em><code>HTTP_USER_AGENT</code>
<code>REDIRECT_HTTP_USER_AGENT</code> になります。
これらの新しい変数に加えて、Apache は、
スクリプトがリダイレクト元のトレースを助けるために
<code>REDIRECT_URL</code><code>REDIRECT_STATUS</code>
を定義します。アクセスログには元の URL とリダイレクトされた URL
の両方が記録されます。</p>
<p>ErrorDocument が CGI スクリプトへのローカルリダイレクトを
指定している場合は、それを起動することになったエラーの状態を
クライアントまで確実に伝えるために <code>"Status:" </code>
ヘッダを含むべきです。例えば、ErrorDocument 用の Perl
スクリプトは以下のようなものを含むかもしれません。
</p>
<div class="example"><p><code>
... <br />
print "Content-type: text/html\n"; <br />
printf "Status: %s Condition Intercepted\n", $ENV{"REDIRECT_STATUS"}; <br />
...
</code></p></div>
<p>スクリプトが <code>404 Not Found</code> のような
特定のエラーコンディションを扱うためだけに使われる場合は、
代わりに特定のコードとエラーテキストを使用することができます。</p>
</div></div>
<div class="bottomlang">
<p><span>翻訳済み言語: </span><a href="./en/custom-error.html" hreflang="en" rel="alternate" title="English">&nbsp;en&nbsp;</a> |
<a href="./es/custom-error.html" hreflang="es" rel="alternate" title="Español">&nbsp;es&nbsp;</a> |
<a href="./fr/custom-error.html" hreflang="fr" rel="alternate" title="Français">&nbsp;fr&nbsp;</a> |
<a href="./ja/custom-error.html" title="Japanese">&nbsp;ja&nbsp;</a> |
<a href="./ko/custom-error.html" hreflang="ko" rel="alternate" title="Korean">&nbsp;ko&nbsp;</a> |
<a href="./tr/custom-error.html" hreflang="tr" rel="alternate" title="Türkçe">&nbsp;tr&nbsp;</a></p>
</div><div class="top"><a href="#page-header"><img src="./images/up.gif" alt="top" /></a></div><div class="section"><h2><a id="comments_section" name="comments_section">コメント</a></h2><div class="warning"><strong>Notice:</strong><br />This is not a Q&amp;A section. Comments placed here should be pointed towards suggestions on improving the documentation or server, and may be removed again by our moderators if they are either implemented or considered invalid/off-topic. Questions on how to manage the Apache HTTP Server should be directed at either our IRC channel, #httpd, on Freenode, or sent to our <a href="http://httpd.apache.org/lists.html">mailing lists</a>.</div>
<script type="text/javascript"><!--//--><![CDATA[//><!--
var comments_shortname = 'httpd';
var comments_identifier = 'http://httpd.apache.org/docs/trunk/custom-error.html';
(function(w, d) {
if (w.location.hostname.toLowerCase() == "httpd.apache.org") {
d.write('<div id="comments_thread"><\/div>');
var s = d.createElement('script');
s.type = 'text/javascript';
s.async = true;
s.src = 'https://comments.apache.org/show_comments.lua?site=' + comments_shortname + '&page=' + comments_identifier;
(d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0]).appendChild(s);
}
else {
d.write('<div id="comments_thread">Comments are disabled for this page at the moment.<\/div>');
}
})(window, document);
//--><!]]></script></div><div id="footer">
<p class="apache">Copyright 2016 The Apache Software Foundation.<br />この文書は <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a> のライセンスで提供されています。.</p>
<p class="menu"><a href="./mod/">モジュール</a> | <a href="./mod/quickreference.html">ディレクティブ</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="./glossary.html">用語</a> | <a href="./sitemap.html">サイトマップ</a></p></div><script type="text/javascript"><!--//--><![CDATA[//><!--
if (typeof(prettyPrint) !== 'undefined') {
prettyPrint();
}
//--><!]]></script>
</body></html>