sections.html.ja.utf8 32.8 KB
Newer Older
powelld's avatar
powelld committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523
<?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.4</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/directives.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.4</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.4</a></div><div id="page-content"><div id="preamble"><h1>セクションの設定</h1>
<div class="toplang">
<p><span>翻訳済み言語: </span><a href="./en/sections.html" hreflang="en" rel="alternate" title="English">&nbsp;en&nbsp;</a> |
<a href="./fr/sections.html" hreflang="fr" rel="alternate" title="Français">&nbsp;fr&nbsp;</a> |
<a href="./ja/sections.html" title="Japanese">&nbsp;ja&nbsp;</a> |
<a href="./ko/sections.html" hreflang="ko" rel="alternate" title="Korean">&nbsp;ko&nbsp;</a> |
<a href="./tr/sections.html" hreflang="tr" rel="alternate" title="Türkçe">&nbsp;tr&nbsp;</a></p>
</div>
<div class="outofdate">この日本語訳はすでに古くなっている
            可能性があります。
            最近更新された内容を見るには英語版をご覧下さい。
        </div>
 <p><a href="configuring.html">設定ファイル</a>中のディレクティブは
サーバ全体に適用されたり、特定のディレクトリやファイル、ホスト、URL にのみ
適用されるように制限したりすることができます。この文書は設定用のセクションの
コンテナや <code>.htaccess</code> ファイルを使って他の設定ディレクティブの
スコープを変更する方法を説明します。</p>
</div>
<div id="quickview"><a href="https://www.apache.org/foundation/contributing.html" class="badge"><img src="https://www.apache.org/images/SupportApache-small.png" alt="Support Apache!" /></a><ul id="toc"><li><img alt="" src="./images/down.gif" /> <a href="#types">設定用セクションコンテナの種類</a></li>
<li><img alt="" src="./images/down.gif" /> <a href="#file-and-web">ファイルシステムとウェブ空間</a></li>
<li><img alt="" src="./images/down.gif" /> <a href="#virtualhost">バーチャルホスト</a></li>
<li><img alt="" src="./images/down.gif" /> <a href="#proxy">プロクシ</a></li>
<li><img alt="" src="./images/down.gif" /> <a href="#whatwhere">どのディレクティブが使えるの?</a></li>
<li><img alt="" src="./images/down.gif" /> <a href="#mergin">セクションのマージ方法</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="types" id="types">設定用セクションコンテナの種類</a></h2>

<table class="related"><tr><th>関連モジュール</th><th>関連ディレクティブ</th></tr><tr><td><ul><li><code class="module"><a href="./mod/core.html">core</a></code></li><li><code class="module"><a href="./mod/mod_version.html">mod_version</a></code></li><li><code class="module"><a href="./mod/mod_proxy.html">mod_proxy</a></code></li></ul></td><td><ul><li><code class="directive"><a href="./mod/core.html#directory">&lt;Directory&gt;</a></code></li><li><code class="directive"><a href="./mod/core.html#directorymatch">&lt;DirectoryMatch&gt;</a></code></li><li><code class="directive"><a href="./mod/core.html#files">&lt;Files&gt;</a></code></li><li><code class="directive"><a href="./mod/core.html#filesmatch">&lt;FilesMatch&gt;</a></code></li><li><code class="directive"><a href="./mod/core.html#ifdefine">&lt;IfDefine&gt;</a></code></li><li><code class="directive"><a href="./mod/core.html#ifmodule">&lt;IfModule&gt;</a></code></li><li><code class="directive"><a href="./mod/mod_version.html#ifversion">&lt;IfVersion&gt;</a></code></li><li><code class="directive"><a href="./mod/core.html#location">&lt;Location&gt;</a></code></li><li><code class="directive"><a href="./mod/core.html#locationmatch">&lt;LocationMatch&gt;</a></code></li><li><code class="directive"><a href="./mod/mod_proxy.html#proxy">&lt;Proxy&gt;</a></code></li><li><code class="directive"><a href="./mod/mod_proxy.html#proxymatch">&lt;ProxyMatch&gt;</a></code></li><li><code class="directive"><a href="./mod/core.html#virtualhost">&lt;VirtualHost&gt;</a></code></li></ul></td></tr></table>

<p>コンテナには二つの基本となる種類があります。ほとんどのコンテナは
各リクエストに対して評価されます。その場合、コンテナ中のディレクティブは
コンテナにマッチするリクエストにのみ適用されます。一方、
<code class="directive"><a href="./mod/core.html#ifdefine">&lt;IfDefine&gt;</a></code>, 
<code class="directive"><a href="./mod/core.html#ifmodule">&lt;IfModule&gt;</a></code>, 
<code class="directive"><a href="./mod/mod_version.html#ifversion">&lt;IfVersion&gt;</a></code>
コンテナは
サーバの起動時と再起動時にのみ評価されます。起動時に条件が真であれば、
コンテナ中のディレクティブはすべてのリクエストに適用されます。条件が
偽であれば、コンテナ中のディレクティブは無視されます。</p>

<p><code class="directive"><a href="./mod/core.html#ifdefine">&lt;IfDefine&gt;</a></code> ディレクティブは
<code class="program"><a href="./programs/httpd.html">httpd</a></code> コマンドラインで適切なパラメータが定義されたときにのみ
適用されるディレクティブを囲います。例えば次の設定では、サーバが
<code>httpd -DClosedForNow</code> を使って起動されたときだけすべての
リクエストを別のサイトにリダイレクトします:</p>

<div class="example"><p><code>
&lt;IfDefine ClosedForNow&gt;<br />
Redirect / http://otherserver.example.com/<br />
&lt;/IfDefine&gt;
</code></p></div>

<p><code class="directive"><a href="./mod/core.html#ifmodule">&lt;IfModule&gt;</a></code>
非常に似ていますが、代わりにサーバ上でモジュールが使用可能な場合にのみ
適用可能なディレクティブを囲います。モジュールはサーバに
静的に組み込まれているか、動的に組み込むようになっていて、設定ファイル中で
<code class="directive"><a href="./mod/mod_so.html#loadmodule">LoadModule</a></code> の行がより前の
部分に書かれている必要があります。このディレクティブは特定のモジュールの
存在に関わらず設定ファイルが動作する必要がある場合にのみ使ってください。
常に動作して欲しいディレクティブを囲むために使うべきではありません。
存在しないモジュールに関する有用なエラーメッセージの発生を抑制してしまいますので。
</p>

<p>次の例では、<code class="module"><a href="./mod/mod_mime_magic.html">mod_mime_magic</a></code> があるときにのみ <code class="directive"><a href="./mod/mod_mime_magic.html#mimemagicfiles">MimeMagicFiles</a></code> ディレクティブが
適用されます。</p>

<div class="example"><p><code>
&lt;IfModule mod_mime_magic.c&gt;<br />
MimeMagicFile conf/magic<br />
&lt;/IfModule&gt;
</code></p></div>

<p><code class="directive"><a href="./mod/mod_version.html#ifversion">&lt;IfVersion&gt;</a></code>
ディレクティブは
<code class="directive"><a href="./mod/core.html#ifdefine">&lt;IfDefine&gt;</a></code>
<code class="directive"><a href="./mod/core.html#ifmodule">&lt;IfModule&gt;</a></code>と、
とてもよく似ていますが、稼働中のサーバのバージョンが特定のバージョンの時にのみ
適用されます。様々なバージョンの httpd を様々な設定で動作させることになる場合で、
テストスイートや巨大なネットワークでの用途を想定して、
このモジュールは設計されています。</p>

<div class="example"><p><code>
  &lt;IfVersion &gt;= 2.1&gt;<br />
  <span class="indent">
    # this happens only in versions greater or<br />
    # equal 2.1.0.<br />
  </span>
  &lt;/IfVersion&gt;
</code></p></div>

<p><code class="directive"><a href="./mod/core.html#ifdefine">&lt;IfDefine&gt;</a></code>, 
<code class="directive"><a href="./mod/core.html#ifmodule">&lt;IfModule&gt;</a></code>,
<code class="directive"><a href="./mod/mod_version.html#ifversion">&lt;IfVersion&gt;</a></code> ディレクティブは
テストの前に "!" を付けることで否定の条件を適用することができます。
また、これらのセクションはより複雑な制限を課すために入れ子にすることができます。
</p>
</div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
<div class="section">
<h2><a name="file-and-web" id="file-and-web">ファイルシステムとウェブ空間</a></h2>

<p>最もよく使われる設定のセクションコンテナはファイルシステムやウェブ空間の
特定の場所の設定を変更するものです。まず、この二つの違いを理解することが
大切です。ファイルシステムはオペレーティングシステムから見たディスクの内容です。
たとえば、デフォルトのインストールでは Apache は Unix ファイルシステムでは
<code>/usr/local/apache2</code> に、Windows ファイルシステムでは
<code>"c:/Program Files/Apache Group/Apache2"</code> に存在します。
(Apache では Windows でもパスセパレータとしてスラッシュを使うことに
気をつけてください。) 対照的に、ウェブ空間はあなたのサイトを
ウェブサーバから配信されるものとして見たもので、クライアントに見えるものです。
デフォルトの Unix 上の Apache のインストールではウェブ空間の
<code>/dir/</code> というパスはファイルシステムの
<code>/usr/local/apache2/htdocs/dir/</code> というパスに対応します。
ウェブページはデータベースや他の場所から動的に生成することもできますので、
ウェブ空間はファイルシステムに直接マップする必要はありません。</p>

<h3><a name="filesystem" id="filesystem">ファイルシステムコンテナ</a></h3>

<p><code class="directive"><a href="./mod/core.html#directory">&lt;Directory&gt;</a></code> ディレクティブと
<code class="directive"><a href="./mod/core.html#files">&lt;Files&gt;</a></code> ディレクティブ、それと
それらの正規表現版はディレクティブをファイルシステムの一部分に対して適用します。
<code class="directive"><a href="./mod/core.html#directory">&lt;Directory&gt;</a></code> セクションの
中のディレクティブは指定されたディレクトリとそのすべてのサブディレクトリに
適用されます。<a href="howto/htaccess.html">.htaccess ファイル</a>
使うことでも同じ効果を得ることができます。例えば、次の設定では
<code>/var/web/dir1</code> とすべてのサブディレクトリに対して
ディレクトリインデックスを行ないます。</p>

<div class="example"><p><code>
&lt;Directory /var/web/dir1&gt;<br />
Options +Indexes<br />
&lt;/Directory&gt;
</code></p></div>

<p><code class="directive"><a href="./mod/core.html#files">&lt;Files&gt;</a></code> セクションの
中にあるディレクティブはどのディレクトリにあるかに関わらず、指定された名前の
すべてのファイルに適用されます。ですから例えば以下の設定ディレクティブが
設定ファイルの主セクションに書かれたときには、すべての場所の
<code>private.html</code> という名前のファイルへのアクセスを拒否します。</p>

<div class="example"><p><code>
&lt;Files private.html&gt;<br />
Order allow,deny<br />
Deny from all<br />
&lt;/Files&gt;
</code></p></div>

<p>ファイルシステムの特定の場所にあるファイルを指定するために、
<code class="directive"><a href="./mod/core.html#files">&lt;Files&gt;</a></code> セクションと
<code class="directive"><a href="./mod/core.html#directory">&lt;Directory&gt;</a></code> セクションを
組み合わせることができます。例えば、次の設定では
<code>/var/web/dir1/private.html</code>, 
<code>/var/web/dir1/subdir2/private.html</code>, 
<code>/var/web/dir1/subdir3/private.html</code> など、
<code>/var/web/dir1/</code> ディレクトリの下にあるすべての
<code>private.html</code> へのアクセスを拒否します。</p>

<div class="example"><p><code>
&lt;Directory /var/web/dir1&gt;<br />
&lt;Files private.html&gt;<br />
Order allow,deny<br />
Deny from all<br />
&lt;/Files&gt;<br />
&lt;/Directory&gt;
</code></p></div>


<h3><a name="webspace" id="webspace">ウェブ空間コンテナ</a></h3>

<p>一方、<code class="directive"><a href="./mod/core.html#location">&lt;Location&gt;</a></code>
ディレクティブとその<a class="glossarylink" href="./glossary.html#regex" title="用語集を参照">正規表現</a>版は
ウェブ空間上の内容に対して設定を変更します。
たとえば、次の設定では /private で始まる URL パスへのアクセスを制限します。
具体的には、
<code>http://yoursite.example.com/private</code>,
<code>http://yoursite.example.com/private123</code>, 
<code>http://yoursite.example.com/private/dir/file.html</code> 
へのリクエストや、
他の同様に <code>/private</code> 文字列で始まるリクエストに
適用されます。</p>

<div class="example"><p><code>
&lt;Location /private&gt;<br />
Order Allow,Deny<br />
Deny from all<br />
&lt;/Location&gt;
</code></p></div>

<p><code class="directive"><a href="./mod/core.html#location">&lt;Location&gt;</a></code>
ディレクティブはファイルシステムと関係ある必要が全くありません。
たとえば次の例では、どのようにして特定の URL を
<code class="module"><a href="./mod/mod_status.html">mod_status</a></code>で提供されている Apache 
内部ハンドラにマップするかを示しています。ファイルシステムに
<code>server-status</code> というファイルが存在する必要はありません。</p>

<div class="example"><p><code>
&lt;Location /server-status&gt;<br />
SetHandler server-status<br />
&lt;/Location&gt;
</code></p></div>


<h3><a name="wildcards" id="wildcards">ワイルドカードと正規表現</a></h3>

<p><code class="directive"><a href="./mod/core.html#directory">&lt;Directory&gt;</a></code>, 
<code class="directive"><a href="./mod/core.html#files">&lt;Files&gt;</a></code>, 
<code class="directive"><a href="./mod/core.html#location">&lt;Location&gt;</a></code> 
ディレクティブでは、 C 標準ライブラリの <code>fnmatch</code> のように
shell スタイルのワイルドカードキャラクタが使用できます。
"*" 文字は任意の文字列にマッチし、"?" 文字は任意の 1 文字にマッチし、
"[<em>seq</em>]" は <em>seq</em> の任意の文字にマッチします。
"/" 文字はどのワイルドカードでもマッチされません。
明示的に指定する必要があります。</p>

<p>これより柔軟なマッチングが必要な場合は、これらのコンテナに正規表現
(regex) 版である
<code class="directive"><a href="./mod/core.html#directorymatch">&lt;DirectoryMatch&gt;</a></code>, 
<code class="directive"><a href="./mod/core.html#filesmatch">&lt;FilesMatch&gt;</a></code>, 
<code class="directive"><a href="./mod/core.html#locationmatch">&lt;LocationMatch&gt;</a></code>
があり、マッチを選択するのに perl 互換<a class="glossarylink" href="./glossary.html#regex" title="用語集を参照">正規表現</a>を使用できます。しかし、次の設定のマージに目を通して、
regex セクションを使用することで、ディレクティブの適用がどのように
変化するか把握しておいてください。</p>

<p>全ユーザディレクトリの設定を変更する、非 regex
ワイルドカードセクションは次のようになります。</p>

<div class="example"><p><code>
&lt;Directory /home/*/public_html&gt;<br />
Options Indexes<br />
&lt;/Directory&gt;
</code></p></div>

<p>regex セクションを使用することで、画像ファイルの多くのタイプに対する
アクセスを一度に拒否できます。</p>
<div class="example"><p><code>
&lt;FilesMatch \.(?i:gif|jpe?g|png)$&gt;<br />
Order allow,deny<br />
Deny from all<br />
&lt;/FilesMatch&gt;
</code></p></div>



<h3><a name="whichwhen" id="whichwhen">いつ何を使うか</a></h3>

<p>ファイルシステムコンテナとウェブ空間コンテナを使い分けるのは、
実際には非常に簡単です。ファイルシステムに依存する
オブジェクトにディレクティブを適応する場合は、必ず
<code class="directive"><a href="./mod/core.html#directory">&lt;Directory&gt;</a></code>
<code class="directive"><a href="./mod/core.html#files">&lt;Files&gt;</a></code>
を使用します。ファイルシステムに依存しないオブジェクト
(データベースから生成されるウェブページなど) 
にディレクティブを適用する際には、
<code class="directive"><a href="./mod/core.html#location">&lt;Location&gt;</a></code>
を使用します。</p>

<p>ファイルシステム上のオブジェクトへのアクセスを制限するために、
<code class="directive"><a href="./mod/core.html#location">&lt;Location&gt;</a></code>
を決して使用ないようにしましょう。
同一のファイルシステム位置にマップしている、ウェブ空間位置 (URL)
が多数あって、設定した制限を迂回されてしまうかもしれないからです。
例えば次の設定を考えてみましょう。</p>

<div class="example"><p><code>
&lt;Location /dir/&gt;<br />
Order allow,deny<br />
Deny from all<br />
&lt;/Location&gt;
</code></p></div>

<p><code>http://yoursite.example.com/dir/</code>
へのリクエストでは上手く動作します。しかし大文字小文字を区別しない
ファイルシステムを使っていたらどうなるでしょう?
<code>http://yoursite.example.com/DIR/</code> 
へのリクエストで簡単にアクセス制限を迂回されてしまいます。これに対して
<code class="directive"><a href="./mod/core.html#directory">&lt;Directory&gt;</a></code>
ディレクティブを使用すると、どのように呼び出されたかに関わらず
その場所から提供される内容に適用されます。
(例外はファイルシステムのリンクです。シンボリックリンクを使って、
同一のディレクトリを複数のファイルシステムに設置できます。
<code class="directive"><a href="./mod/core.html#directory">&lt;Directory&gt;</a></code>
ディレクティブはパス名をリセットすることなくシンボリックリンクを
辿ります。ですから、高度なセキュリティが要求される場合は、
適切に <code class="directive"><a href="./mod/core.html#options">Options</a></code> 
ディレクティブを使用してシンボリックリンクを無効にするべきです。)</p>

<p>大文字小文字を区別するファイルシステムを使用しているから上記のことは
無関係だと思われるかもしれませんが、
同一のファイルシステム位置に複数のウェブ空間位置をマップする方法は、
他にいくらでもあるということを覚えていてください。
ですからできる限りファイルシステムコンテナを使用してください。
しかしながら一つだけ例外があります。
<code>&lt;Location /&gt;</code> セクションはどんな URL 
にも関わらず適用されるので、完全に安全です。</p>


</div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
<div class="section">
<h2><a name="virtualhost" id="virtualhost">バーチャルホスト</a></h2>

<p><code class="directive"><a href="./mod/core.html#virtualhost">&lt;VirtualHost&gt;</a></code>
コンテナは特定のホストに適用するディレクティブを格納します。
一台のマシンで複数のホストを異なる設定で提供したいときに有用です。
詳細に関しては<a href="vhosts/">バーチャルホストドキュメント</a>
ご覧下さい。</p>
</div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
<div class="section">
<h2><a name="proxy" id="proxy">プロクシ</a></h2>

<p><code class="directive"><a href="./mod/mod_proxy.html#proxy">&lt;Proxy&gt;</a></code>
<code class="directive"><a href="./mod/mod_proxy.html#proxymatch">&lt;ProxyMatch&gt;</a></code>
コンテナは、特定の URL にマッチする <code class="module"><a href="./mod/mod_proxy.html">mod_proxy</a></code>
プロクシサーバを経由してアクセスしたサイトに対してのみ適用される
設定ディレクティブを格納します。例えば次の設定は、<code>cnn.com</code> 
ウェブサイトにアクセスするために用いられるプロクシサーバを
制限します。</p>

<div class="example"><p><code>
&lt;Proxy http://cnn.com/*&gt;<br />
Order allow,deny<br />
Deny from all<br />
&lt;/Proxy&gt;
</code></p></div>
</div><div class="top"><a href="#page-header"><img alt="top" src="./images/up.gif" /></a></div>
<div class="section">
<h2><a name="whatwhere" id="whatwhere">どのディレクティブが使えるの?</a></h2>

<p>どのタイプの設定セクションでどのディレクティブが使用できるかは、
ディレクティブの <a href="mod/directive-dict.html#Context">Context</a>
を見てください。
<code class="directive"><a href="./mod/core.html#directory">&lt;Directory&gt;</a></code>
で使用可能なものは全て、同様に
<code class="directive"><a href="./mod/core.html#directorymatch">&lt;DirectoryMatch&gt;</a></code>,
<code class="directive"><a href="./mod/core.html#files">&lt;Files&gt;</a></code>,
<code class="directive"><a href="./mod/core.html#filesmatch">&lt;FilesMatch&gt;</a></code>,
<code class="directive"><a href="./mod/core.html#location">&lt;Location&gt;</a></code>,
<code class="directive"><a href="./mod/core.html#locationmatch">&lt;LocationMatch&gt;</a></code>,
<code class="directive"><a href="./mod/mod_proxy.html#proxy">&lt;Proxy&gt;</a></code>,
<code class="directive"><a href="./mod/mod_proxy.html#proxymatch">&lt;ProxyMatch&gt;</a></code>
セクションで使用可能です。しかしながら幾つか例外も存在します。</p>

<ul>
<li><code class="directive"><a href="./mod/core.html#allowoverride">AllowOverride</a></code> ディレクティブは
<code class="directive"><a href="./mod/core.html#directory">&lt;Directory&gt;</a></code>
セクションでのみ使用可能です。</li>

<li><code>FollowSymLinks</code><code>SymLinksIfOwnerMatch</code>
<code class="directive"><a href="./mod/core.html#options">Options</a></code> は、
<code class="directive"><a href="./mod/core.html#directory">&lt;Directory&gt;</a></code>
セクションか <code>.htaccess</code> ファイルでのみ使用可能です。</li>

<li><code class="directive"><a href="./mod/core.html#options">Options</a></code> ディレクティブは、
<code class="directive"><a href="./mod/core.html#files">&lt;Files&gt;</a></code>
<code class="directive"><a href="./mod/core.html#filesmatch">&lt;FilesMatch&gt;</a></code>
セクションでは使用できません。</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="mergin" id="mergin">セクションのマージ方法</a></h2>

    <p>マージの順番は以下のようになっています:</p>

    <ol>
      <li><code class="directive"><a href="./mod/core.html#directory">&lt;Directory&gt;</a></code> (正規表現無し) と
      <code>.htaccess</code> を同時に (<code>.htaccess</code> が許可されていれば、それが
      <code class="directive"><a href="./mod/core.html#directory">&lt;Directory&gt;</a></code> を上書きします)
      </li>

      <li><code class="directive"><a href="./mod/core.html#directorymatch">&lt;DirectoryMatch&gt;</a></code>
      (と <code>&lt;Directory ~&gt;</code></li>

      <li><code class="directive"><a href="./mod/core.html#files">&lt;Files&gt;</a></code>
      <code class="directive"><a href="./mod/core.html#filesmatch">&lt;FilesMatch&gt;</a></code> を同時に</li>

      <li><code class="directive"><a href="./mod/core.html#location">&lt;Location&gt;</a></code>
      <code class="directive"><a href="./mod/core.html#locationmatch">&lt;LocationMatch&gt;</a></code> を同時に</li>
    </ol>

    <p><code class="directive"><a href="./mod/core.html#directory">&lt;Directory&gt;</a></code>
    以外は、それぞれのグループは設定ファイルに現れた順番に処理されます。
    <code class="directive"><a href="./mod/core.html#directory">&lt;Directory&gt;</a></code> (上のグループ 1)
    はディレクトリが短いものから長いものへと処理されます。ですから、
    例えば <code>&lt;Directory /var/web/dir1&gt;</code>
    <code>&lt;Directory /var/web/dir/subdir&gt;</code> の前に処理されます。複数の
    <code class="directive"><a href="./mod/core.html#directory">&lt;Directory&gt;</a></code> セクションが
    同じディレクトリに
    適用される場合は、設定ファイル中の順番に従って処理されます。
    <code class="directive"><a href="./mod/core.html#include">Include</a></code>
    によって挿入された設定は 挿入しているファイルの
    <code class="directive"><a href="./mod/core.html#include">Include</a></code>
    ディレクティブの位置にあったかのように扱われます。</p>

    <p><code class="directive"><a href="./mod/core.html#virtualhost">&lt;VirtualHost&gt;</a></code> セクション中のセクションは
    バーチャルホストの定義の外側の対応するセクションの
    <em></em>に適用されます。これによりバーチャルホストが
    メインのサーバ設定を上書きできるようなります。</p>

    <p><code class="module"><a href="./mod/mod_proxy.html">mod_proxy</a></code> でリクエストが処理される場合は、
    処理順番のうち、<code class="directive"><a href="./mod/core.html#directory">&lt;Directory&gt;</a></code> コンテナの部分が
    <code class="directive"><a href="./mod/mod_proxy.html#proxy">&lt;Proxy&gt;</a></code>
    コンテナに取って代わられます。</p>

    <p>後のセクションのディレクティブが前のセクションのものを上書きします。</p>


<div class="note"><h3>技術メモ</h3>
      実際には、名前を変換する段階 (URL
      をファイル名にマップするために <code>Alias</code>
      <code>DocumentRoot</code> が使用されるところ) の直前に
      <code class="directive"><a href="./mod/core.html#location">&lt;Location&gt;</a></code>/<code class="directive"><a href="./mod/core.html#locationmatch">&lt;LocationMatch&gt;</a></code>
      が行なわれます。
      これらを適用した結果は変換が終わった後に完全に捨てられます。
</div>
<h3><a name="merge-examples" id="merge-examples"></a></h3>

<p>次はマージの順番を示すための恣意的な例になっています。
リクエスト全てに適用されるとして、本例のディレクティブは
A &gt; B &gt; C &gt; D &gt; E の順番に適用されます。</p>

<div class="example"><p><code>
&lt;Location /&gt;<br />
E<br />
&lt;/Location&gt;<br />
<br />
&lt;Files f.html&gt;<br />
D<br />
&lt;/Files&gt;<br />
<br />
&lt;VirtualHost *&gt;<br />
&lt;Directory /a/b&gt;<br />
B<br />
&lt;/Directory&gt;<br />
&lt;/VirtualHost&gt;<br />
<br />
&lt;DirectoryMatch "^.*b$"&gt;<br />
C<br />
&lt;/DirectoryMatch&gt;<br />
<br />
&lt;Directory /a/b&gt;<br />
A<br />
&lt;/Directory&gt;<br />
<br />
</code></p></div>

<p>もっと具体的な、次の例を考えてみましょう。
<code class="directive"><a href="./mod/core.html#directory">&lt;Directory&gt;</a></code> 
セクションに設置されたアクセス制限に関わらず、
<code class="directive"><a href="./mod/core.html#location">&lt;Location&gt;</a></code>
セクションが最後に評価されて、サーバへのアクセスは制限されません。
言い換えれば、マージの順番は重要で、注意して使用してください!</p>

<div class="example"><p><code>
&lt;Location /&gt;<br />
Order deny,allow<br />
Allow from all<br />
&lt;/Location&gt;<br />
<br />
# Woops!  This &lt;Directory&gt; section will have no effect<br />
&lt;Directory /&gt;<br />
Order allow,deny<br />
Allow from all<br />
Deny from badguy.example.com<br />
&lt;/Directory&gt;
</code></p></div>



</div></div>
<div class="bottomlang">
<p><span>翻訳済み言語: </span><a href="./en/sections.html" hreflang="en" rel="alternate" title="English">&nbsp;en&nbsp;</a> |
<a href="./fr/sections.html" hreflang="fr" rel="alternate" title="Français">&nbsp;fr&nbsp;</a> |
<a href="./ja/sections.html" title="Japanese">&nbsp;ja&nbsp;</a> |
<a href="./ko/sections.html" hreflang="ko" rel="alternate" title="Korean">&nbsp;ko&nbsp;</a> |
<a href="./tr/sections.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/2.4/sections.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 2017 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/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[//><!--
if (typeof(prettyPrint) !== 'undefined') {
    prettyPrint();
}
//--><!]]></script>
</body></html>