1<?xml version="1.0" encoding="UTF-8"?> 2<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 3<html xmlns="http://www.w3.org/1999/xhtml" lang="ja" xml:lang="ja"><head><!-- 4 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 5 This file is generated from xml source: DO NOT EDIT 6 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX 7 --> 8<title>カスタムエラーレスポンス - Apache HTTP サーバ</title> 9<link href="/style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" /> 10<link href="/style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" /> 11<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" /> 12<script src="/style/scripts/prettify.js" type="text/javascript"> 13</script> 14 15<link href="/images/favicon.ico" rel="shortcut icon" /></head> 16<body id="manual-page"><div id="page-header"> 17<p class="menu"><a href="/mod/">モジュール</a> | <a href="/mod/directives.html">ディレクティブ</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="/glossary.html">用語</a> | <a href="/sitemap.html">サイトマップ</a></p> 18<p class="apache">Apache HTTP サーバ バージョン 2.2</p> 19<img alt="" src="/images/feather.gif" /></div> 20<div class="up"><a href="./"><img title="<-" alt="<-" src="/images/left.gif" /></a></div> 21<div id="path"> 22<a href="http://www.apache.org/">Apache</a> > <a href="http://httpd.apache.org/">HTTP サーバ</a> > <a href="http://httpd.apache.org/docs/">ドキュメンテーション</a> > <a href="./">バージョン 2.2</a></div><div id="page-content"><div id="preamble"><h1>カスタムエラーレスポンス</h1> 23<div class="toplang"> 24<p><span>翻訳済み言語: </span><a href="/en/custom-error.html" hreflang="en" rel="alternate" title="English"> en </a> | 25<a href="/es/custom-error.html" hreflang="es" rel="alternate" title="Español"> es </a> | 26<a href="/ja/custom-error.html" title="Japanese"> ja </a> | 27<a href="/ko/custom-error.html" hreflang="ko" rel="alternate" title="Korean"> ko </a> | 28<a href="/tr/custom-error.html" hreflang="tr" rel="alternate" title="Türkçe"> tr </a></p> 29</div> 30<div class="outofdate">この日本語訳はすでに古くなっている 31 可能性があります。 32 最近更新された内容を見るには英語版をご覧下さい。 33 </div> 34 35 <p>ウェブマスターが何らかのエラーや問題に対する 36 Apache の反応を設定できるようにする追加機能を提供します。</p> 37 38 <p>サーバがエラーや問題を発見した場合の反応を、 39 カスタマイズして定義することができます。</p> 40 41 <p>スクリプトの実行が失敗して "500 Server Error" 42 を発生させたとします。この場合の反応を、より好ましいテキストや、別の 43 URL (内部及び外部) へのリダイレクションに置き換えることができます。 44 </p> 45 </div> 46<div id="quickview"><ul id="toc"><li><img alt="" src="/images/down.gif" /> <a href="#behavior">動作</a></li> 47<li><img alt="" src="/images/down.gif" /> <a href="#configuration">設定</a></li> 48<li><img alt="" src="/images/down.gif" /> <a href="#custom">カスタムエラーレスポンスとリダイレクト</a></li> 49</ul><ul class="seealso"><li><a href="#comments_section">コメント</a></li></ul></div> 50<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div> 51<div class="section"> 52<h2><a name="behavior" id="behavior">動作</a></h2> 53 54 55 <h3>古い動作</h3> 56 57 58 <p>NCSA httpd 1.3 は、古くて退屈なエラー/問題メッセージを 59 返していました。それはしばしばユーザには無意味であり、 60 またそれを発生させた原因を記録する方法も提供していませんでした。</p> 61 62 63 <h3>新しい動作</h3> 64 65 66 <ol> 67 <li>NCSA のハードコードされたメッセージの代わりに 68 他のテキストを表示</li> 69 70 <li>ローカルの URL にリダイレクト</li> 71 72 <li>外部の URL にリダイレクト</li> 73 </ol> 74 75 <p>するようにサーバを設定できます。</p> 76 77 <p>別の URL にリダイレクトすることは役に立ちますが、 78 それは説明をしたり、より明確に誤り/問題を記録したりするために 79 何か情報を伝えられるときに限ります。</p> 80 81 <p>これを実現するために、 Apache は新しく CGI のような環境変数を 82 定義します:</p> 83 84 <div class="example"><p><code> 85 REDIRECT_HTTP_ACCEPT=*/*, image/gif, 86 image/x-xbitmap, image/jpeg<br /> 87 REDIRECT_HTTP_USER_AGENT=Mozilla/1.1b2 (X11; I; HP-UX 88 A.09.05 9000/712)<br /> 89 REDIRECT_PATH=.:/bin:/usr/local/bin:/etc<br /> 90 REDIRECT_QUERY_STRING=<br /> 91 REDIRECT_REMOTE_ADDR=121.345.78.123<br /> 92 REDIRECT_REMOTE_HOST=ooh.ahhh.com<br /> 93 REDIRECT_SERVER_NAME=crash.bang.edu<br /> 94 REDIRECT_SERVER_PORT=80<br /> 95 REDIRECT_SERVER_SOFTWARE=Apache/0.8.15<br /> 96 REDIRECT_URL=/cgi-bin/buggy.pl 97 </code></p></div> 98 99 <p>頭に付く <code>REDIRECT_</code> に注目してください。</p> 100 101 <p>少なくとも <code>REDIRECT_URL</code> と 102 <code>REDIRECT_QUERY_STRING</code> は新しい URL (CGI スクリプトか 103 CGI インクルードであると仮定されます) に渡されます。 104 他の変数は、エラーや問題が起きる前に存在した場合にだけ存在します。 105 もしあなたの設定した <code class="directive"><a href="/mod/core.html#errordocument">ErrorDocument</a></code> が <em>外部</em>リダイレクト 106 (<em>すなわち</em>、<code>http:</code> 107 のような体系名から始まるすべてのもの。たとえ同じホストを指していても) 108 ならば、これらは<strong>まったく</strong>設定されません。</p> 109 110 </div><div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div> 111<div class="section"> 112<h2><a name="configuration" id="configuration">設定</a></h2> 113 114 115 <p><code class="directive"><a href="/mod/core.html#allowoverride">AllowOverride</a></code> が適切に設定されていれば、 116 .htaccess ファイルで <code class="directive"><a href="/mod/core.html#errordocument">ErrorDocument</a></code> 117 を使用することができます。</p> 118 119 <p>ここに、いくつかの例を挙げます。</p> 120 121 <div class="example"><p><code> 122 ErrorDocument 500 /cgi-bin/crash-recover <br /> 123 ErrorDocument 500 "Sorry, our script crashed. Oh dear" <br /> 124 ErrorDocument 500 http://xxx/ <br /> 125 ErrorDocument 404 /Lame_excuses/not_found.html <br /> 126 ErrorDocument 401 /Subscription/how_to_subscribe.html 127 </code></p></div> 128 129 <p>構文</p> 130 131 <div class="example"><p><code> 132 ErrorDocument <3-digit-code> <action> 133 </code></p></div> 134 135 <p>action (動作) は、</p> 136 137 <ol> 138 <li>表示されるべきテキスト。テキストには引用符 (") をつけます。 139 引用符の後に続くものが何でも表示されます。 140 <em>注意 : (") は表示されません</em></li> 141 142 <li>リダイレクト先の外部 URL </li> 143 144 <li>リダイレクト先のローカル URL </li> 145 </ol> 146 </div><div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div> 147<div class="section"> 148<h2><a name="custom" id="custom">カスタムエラーレスポンスとリダイレクト</a></h2> 149 150 151 <p>スクリプト/SSI に追加の環境変数が利用可能になるように、 152 リダイレクトされた URL に対する Apache の動作が変更されました。</p> 153 154 <h3>古い動作</h3> 155 156 157 <p>リダイレクトされたスクリプトは標準の CGI 158 環境変数を利用可能でした。しかし、どこからリダイレクト 159 されたかの情報は提供されていませんでした。</p> 160 161 162 <h3>新しい動作</h3> 163 164 165 <p>リダイレクトされた先のスクリプトが使用可能なように、 166 新しいたくさんの環境変数が初期化されます。新しい変数は、それぞれ 167 <code>REDIRECT_</code> で始まります。 168 <code>REDIRECT_</code> で始まる環境変数はリダイレクトされる前に存在していた 169 CGI 環境変数の頭に <code>REDIRECT_</code> を付けて作成されます。 170 <em>すなわち</em>、<code>HTTP_USER_AGENT</code> は 171 <code>REDIRECT_HTTP_USER_AGENT</code> になります。 172 これらの新しい変数に加えて、Apache は、 173 スクリプトがリダイレクト元のトレースを助けるために 174 <code>REDIRECT_URL</code> と <code>REDIRECT_STATUS</code> 175 を定義します。アクセスログには元の URL とリダイレクトされた URL 176 の両方が記録されます。</p> 177 178 <p>ErrorDocument が CGI スクリプトへのローカルリダイレクトを 179 指定している場合は、それを起動することになったエラーの状態を 180 クライアントまで確実に伝えるために <code>"Status:" </code> 181 ヘッダを含むべきです。例えば、ErrorDocument 用の Perl 182 スクリプトは以下のようなものを含むかもしれません。 183 </p> 184 185 <div class="example"><p><code> 186 ... <br /> 187 print "Content-type: text/html\n"; <br /> 188 printf "Status: %s Condition Intercepted\n", $ENV{"REDIRECT_STATUS"}; <br /> 189 ... 190 </code></p></div> 191 192 <p>スクリプトが <code>404 Not Found</code> のような 193 特定のエラーコンディションを扱うためだけに使われる場合は、 194 代わりに特定のコードとエラーテキストを使用することができます。</p> 195 196 </div></div> 197<div class="bottomlang"> 198<p><span>翻訳済み言語: </span><a href="/en/custom-error.html" hreflang="en" rel="alternate" title="English"> en </a> | 199<a href="/es/custom-error.html" hreflang="es" rel="alternate" title="Español"> es </a> | 200<a href="/ja/custom-error.html" title="Japanese"> ja </a> | 201<a href="/ko/custom-error.html" hreflang="ko" rel="alternate" title="Korean"> ko </a> | 202<a href="/tr/custom-error.html" hreflang="tr" rel="alternate" title="Türkçe"> tr </a></p> 203</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&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> 204<script type="text/javascript"><!--//--><![CDATA[//><!-- 205var comments_shortname = 'httpd'; 206var comments_identifier = 'http://httpd.apache.org/docs/2.2/custom-error.html'; 207(function(w, d) { 208 if (w.location.hostname.toLowerCase() == "httpd.apache.org") { 209 d.write('<div id="comments_thread"><\/div>'); 210 var s = d.createElement('script'); 211 s.type = 'text/javascript'; 212 s.async = true; 213 s.src = 'https://comments.apache.org/show_comments.lua?site=' + comments_shortname + '&page=' + comments_identifier; 214 (d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0]).appendChild(s); 215 } 216 else { 217 d.write('<div id="comments_thread">Comments are disabled for this page at the moment.<\/div>'); 218 } 219})(window, document); 220//--><!]]></script></div><div id="footer"> 221<p class="apache">Copyright 2013 The Apache Software Foundation.<br />この文書は <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a> のライセンスで提供されています。.</p> 222<p class="menu"><a href="/mod/">モジュール</a> | <a href="/mod/directives.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[//><!-- 223if (typeof(prettyPrint) !== 'undefined') { 224 prettyPrint(); 225} 226//--><!]]></script> 227</body></html>