| <?xml version="1.0" encoding="UTF-8" ?> |
| <!DOCTYPE manualpage SYSTEM "./style/manualpage.dtd"> |
| <?xml-stylesheet type="text/xsl" href="./style/manual.ja.xsl"?> |
| <!-- English Revision: 558686:1741842 (outdated) --> |
| |
| <!-- |
| Licensed to the Apache Software Foundation (ASF) under one or more |
| contributor license agreements. See the NOTICE file distributed with |
| this work for additional information regarding copyright ownership. |
| The ASF licenses this file to You under the Apache License, Version 2.0 |
| (the "License"); you may not use this file except in compliance with |
| the License. You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
| --> |
| |
| <manualpage metafile="custom-error.xml.meta"> |
| |
| <title>カスタムエラーレスポンス</title> |
| |
| <summary> |
| <p>ウェブマスターが何らかのエラーや問題に対する |
| Apache の反応を設定できるようにする追加機能を提供します。</p> |
| |
| <p>サーバがエラーや問題を発見した場合の反応を、 |
| カスタマイズして定義することができます。</p> |
| |
| <p>スクリプトの実行が失敗して "500 Server Error" |
| を発生させたとします。この場合の反応を、より好ましいテキストや、別の |
| URL (内部及び外部) へのリダイレクションに置き換えることができます。 |
| </p> |
| </summary> |
| |
| <section id="behavior"> |
| <title>動作</title> |
| |
| <section> |
| <title>古い動作</title> |
| |
| <p>NCSA httpd 1.3 は、古くて退屈なエラー/問題メッセージを |
| 返していました。それはしばしばユーザには無意味であり、 |
| またそれを発生させた原因を記録する方法も提供していませんでした。</p> |
| </section> |
| |
| <section> |
| <title>新しい動作</title> |
| |
| <ol> |
| <li>NCSA のハードコードされたメッセージの代わりに |
| 他のテキストを表示</li> |
| |
| <li>ローカルの URL にリダイレクト</li> |
| |
| <li>外部の URL にリダイレクト</li> |
| </ol> |
| |
| <p>するようにサーバを設定できます。</p> |
| |
| <p>別の URL にリダイレクトすることは役に立ちますが、 |
| それは説明をしたり、より明確に誤り/問題を記録したりするために |
| 何か情報を伝えられるときに限ります。</p> |
| |
| <p>これを実現するために、 Apache は新しく CGI のような環境変数を |
| 定義します:</p> |
| |
| <example> |
| 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 |
| </example> |
| |
| <p>頭に付く <code>REDIRECT_</code> に注目してください。</p> |
| |
| <p>少なくとも <code>REDIRECT_URL</code> と |
| <code>REDIRECT_QUERY_STRING</code> は新しい URL (CGI スクリプトか |
| CGI インクルードであると仮定されます) に渡されます。 |
| 他の変数は、エラーや問題が起きる前に存在した場合にだけ存在します。 |
| もしあなたの設定した <directive |
| module="core">ErrorDocument</directive> が <em>外部</em>リダイレクト |
| (<em>すなわち</em>、<code>http:</code> |
| のような体系名から始まるすべてのもの。たとえ同じホストを指していても) |
| ならば、これらは<strong>まったく</strong>設定されません。</p> |
| </section> |
| </section> |
| |
| <section id="configuration"> |
| <title>設定</title> |
| |
| <p><directive module="core">AllowOverride</directive> が適切に設定されていれば、 |
| .htaccess ファイルで <directive module="core">ErrorDocument</directive> |
| を使用することができます。</p> |
| |
| <p>ここに、いくつかの例を挙げます。</p> |
| |
| <example> |
| 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 |
| </example> |
| |
| <p>構文</p> |
| |
| <example> |
| ErrorDocument <3-digit-code> <action> |
| </example> |
| |
| <p>action (動作) は、下記のいずれかです</p> |
| |
| <ol> |
| <li>表示するテキスト。テキストは引用符 (") で囲んで指定します。</li> |
| |
| <li>リダイレクト先の外部 URL </li> |
| |
| <li>リダイレクト先のローカル URL </li> |
| </ol> |
| </section> |
| |
| <section id="custom"> |
| <title>カスタムエラーレスポンスとリダイレクト</title> |
| |
| <p>スクリプト/SSI に追加の環境変数が利用可能になるように、 |
| リダイレクトされた URL に対する Apache の動作が変更されました。</p> |
| |
| <section> |
| <title>古い動作</title> |
| |
| <p>リダイレクトされたスクリプトは標準の CGI |
| 環境変数を利用可能でした。しかし、どこからリダイレクト |
| されたかの情報は提供されていませんでした。</p> |
| </section> |
| |
| <section> |
| <title>新しい動作</title> |
| |
| <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> |
| |
| <example> |
| ... <br /> |
| print "Content-type: text/html\n"; <br /> |
| printf "Status: %s Condition Intercepted\n", $ENV{"REDIRECT_STATUS"}; <br /> |
| ... |
| </example> |
| |
| <p>スクリプトが <code>404 Not Found</code> のような |
| 特定のエラーコンディションを扱うためだけに使われる場合は、 |
| 代わりに特定のコードとエラーテキストを使用することができます。</p> |
| </section> |
| </section> |
| </manualpage> |