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.min.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.4</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.4</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="/fr/custom-error.html" hreflang="fr" rel="alternate" title="Français"> fr </a> | 27<a href="/ja/custom-error.html" title="Japanese"> ja </a> | 28<a href="/ko/custom-error.html" hreflang="ko" rel="alternate" title="Korean"> ko </a> | 29<a href="/tr/custom-error.html" hreflang="tr" rel="alternate" title="Türkçe"> tr </a></p> 30</div> 31<div class="outofdate">この日本語訳はすでに古くなっている 32 可能性があります。 33 最近更新された内容を見るには英語版をご覧下さい。 34 </div> 35 36 <p>ウェブマスターが何らかのエラーや問題に対する 37 Apache の反応を設定できるようにする追加機能を提供します。</p> 38 39 <p>サーバがエラーや問題を発見した場合の反応を、 40 カスタマイズして定義することができます。</p> 41 42 <p>スクリプトの実行が失敗して "500 Server Error" 43 を発生させたとします。この場合の反応を、より好ましいテキストや、別の 44 URL (内部及び外部) へのリダイレクションに置き換えることができます。 45 </p> 46 </div> 47<div id="quickview"><ul id="toc"><li><img alt="" src="/images/down.gif" /> <a href="#behavior">動作</a></li> 48<li><img alt="" src="/images/down.gif" /> <a href="#configuration">設定</a></li> 49<li><img alt="" src="/images/down.gif" /> <a href="#custom">カスタムエラーレスポンスとリダイレクト</a></li> 50</ul><ul class="seealso"><li><a href="#comments_section">コメント</a></li></ul></div> 51<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div> 52<div class="section"> 53<h2><a name="behavior" id="behavior">動作</a></h2> 54 55 56 <h3>古い動作</h3> 57 58 59 <p>NCSA httpd 1.3 は、古くて退屈なエラー/問題メッセージを 60 返していました。それはしばしばユーザには無意味であり、 61 またそれを発生させた原因を記録する方法も提供していませんでした。</p> 62 63 64 <h3>新しい動作</h3> 65 66 67 <ol> 68 <li>NCSA のハードコードされたメッセージの代わりに 69 他のテキストを表示</li> 70 71 <li>ローカルの URL にリダイレクト</li> 72 73 <li>外部の URL にリダイレクト</li> 74 </ol> 75 76 <p>するようにサーバを設定できます。</p> 77 78 <p>別の URL にリダイレクトすることは役に立ちますが、 79 それは説明をしたり、より明確に誤り/問題を記録したりするために 80 何か情報を伝えられるときに限ります。</p> 81 82 <p>これを実現するために、 Apache は新しく CGI のような環境変数を 83 定義します:</p> 84 85 <div class="example"><p><code> 86 REDIRECT_HTTP_ACCEPT=*/*, image/gif, 87 image/x-xbitmap, image/jpeg<br /> 88 REDIRECT_HTTP_USER_AGENT=Mozilla/1.1b2 (X11; I; HP-UX 89 A.09.05 9000/712)<br /> 90 REDIRECT_PATH=.:/bin:/usr/local/bin:/etc<br /> 91 REDIRECT_QUERY_STRING=<br /> 92 REDIRECT_REMOTE_ADDR=121.345.78.123<br /> 93 REDIRECT_REMOTE_HOST=ooh.ahhh.com<br /> 94 REDIRECT_SERVER_NAME=crash.bang.edu<br /> 95 REDIRECT_SERVER_PORT=80<br /> 96 REDIRECT_SERVER_SOFTWARE=Apache/0.8.15<br /> 97 REDIRECT_URL=/cgi-bin/buggy.pl 98 </code></p></div> 99 100 <p>頭に付く <code>REDIRECT_</code> に注目してください。</p> 101 102 <p>少なくとも <code>REDIRECT_URL</code> と 103 <code>REDIRECT_QUERY_STRING</code> は新しい URL (CGI スクリプトか 104 CGI インクルードであると仮定されます) に渡されます。 105 他の変数は、エラーや問題が起きる前に存在した場合にだけ存在します。 106 もしあなたの設定した <code class="directive"><a href="/mod/core.html#errordocument">ErrorDocument</a></code> が <em>外部</em>リダイレクト 107 (<em>すなわち</em>、<code>http:</code> 108 のような体系名から始まるすべてのもの。たとえ同じホストを指していても) 109 ならば、これらは<strong>まったく</strong>設定されません。</p> 110 111 </div><div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div> 112<div class="section"> 113<h2><a name="configuration" id="configuration">設定</a></h2> 114 115 116 <p><code class="directive"><a href="/mod/core.html#allowoverride">AllowOverride</a></code> が適切に設定されていれば、 117 .htaccess ファイルで <code class="directive"><a href="/mod/core.html#errordocument">ErrorDocument</a></code> 118 を使用することができます。</p> 119 120 <p>ここに、いくつかの例を挙げます。</p> 121 122 <div class="example"><p><code> 123 ErrorDocument 500 /cgi-bin/crash-recover <br /> 124 ErrorDocument 500 "Sorry, our script crashed. Oh dear" <br /> 125 ErrorDocument 500 http://xxx/ <br /> 126 ErrorDocument 404 /Lame_excuses/not_found.html <br /> 127 ErrorDocument 401 /Subscription/how_to_subscribe.html 128 </code></p></div> 129 130 <p>構文</p> 131 132 <div class="example"><p><code> 133 ErrorDocument <3-digit-code> <action> 134 </code></p></div> 135 136 <p>action (動作) は、下記のいずれかです</p> 137 138 <ol> 139 <li>表示するテキスト。テキストは引用符 (") で囲んで指定します。</li> 140 141 <li>リダイレクト先の外部 URL </li> 142 143 <li>リダイレクト先のローカル URL </li> 144 </ol> 145 </div><div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div> 146<div class="section"> 147<h2><a name="custom" id="custom">カスタムエラーレスポンスとリダイレクト</a></h2> 148 149 150 <p>スクリプト/SSI に追加の環境変数が利用可能になるように、 151 リダイレクトされた URL に対する Apache の動作が変更されました。</p> 152 153 <h3>古い動作</h3> 154 155 156 <p>リダイレクトされたスクリプトは標準の CGI 157 環境変数を利用可能でした。しかし、どこからリダイレクト 158 されたかの情報は提供されていませんでした。</p> 159 160 161 <h3>新しい動作</h3> 162 163 164 <p>リダイレクトされた先のスクリプトが使用可能なように、 165 新しいたくさんの環境変数が初期化されます。新しい変数は、それぞれ 166 <code>REDIRECT_</code> で始まります。 167 <code>REDIRECT_</code> で始まる環境変数はリダイレクトされる前に存在していた 168 CGI 環境変数の頭に <code>REDIRECT_</code> を付けて作成されます。 169 <em>すなわち</em>、<code>HTTP_USER_AGENT</code> は 170 <code>REDIRECT_HTTP_USER_AGENT</code> になります。 171 これらの新しい変数に加えて、Apache は、 172 スクリプトがリダイレクト元のトレースを助けるために 173 <code>REDIRECT_URL</code> と <code>REDIRECT_STATUS</code> 174 を定義します。アクセスログには元の URL とリダイレクトされた URL 175 の両方が記録されます。</p> 176 177 <p>ErrorDocument が CGI スクリプトへのローカルリダイレクトを 178 指定している場合は、それを起動することになったエラーの状態を 179 クライアントまで確実に伝えるために <code>"Status:" </code> 180 ヘッダを含むべきです。例えば、ErrorDocument 用の Perl 181 スクリプトは以下のようなものを含むかもしれません。 182 </p> 183 184 <div class="example"><p><code> 185 ... <br /> 186 print "Content-type: text/html\n"; <br /> 187 printf "Status: %s Condition Intercepted\n", $ENV{"REDIRECT_STATUS"}; <br /> 188 ... 189 </code></p></div> 190 191 <p>スクリプトが <code>404 Not Found</code> のような 192 特定のエラーコンディションを扱うためだけに使われる場合は、 193 代わりに特定のコードとエラーテキストを使用することができます。</p> 194 195 </div></div> 196<div class="bottomlang"> 197<p><span>翻訳済み言語: </span><a href="/en/custom-error.html" hreflang="en" rel="alternate" title="English"> en </a> | 198<a href="/es/custom-error.html" hreflang="es" rel="alternate" title="Español"> es </a> | 199<a href="/fr/custom-error.html" hreflang="fr" rel="alternate" title="Français"> fr </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.4/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 2014 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>