1 <?xml version="1.0" encoding="UTF-8" ?>
2 <!DOCTYPE modulesynopsis SYSTEM "../style/modulesynopsis.dtd">
3 <?xml-stylesheet type="text/xsl" href="../style/manual.ja.xsl"?>
4 <!-- English Revision: 151408:1861876 (outdated) -->
7 Licensed to the Apache Software Foundation (ASF) under one or more
8 contributor license agreements. See the NOTICE file distributed with
9 this work for additional information regarding copyright ownership.
10 The ASF licenses this file to You under the Apache License, Version 2.0
11 (the "License"); you may not use this file except in compliance with
12 the License. You may obtain a copy of the License at
14 http://www.apache.org/licenses/LICENSE-2.0
16 Unless required by applicable law or agreed to in writing, software
17 distributed under the License is distributed on an "AS IS" BASIS,
18 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 See the License for the specific language governing permissions and
20 limitations under the License.
23 <modulesynopsis metafile="mod_alias.xml.meta">
25 <name>mod_alias</name>
26 <description>ホストファイルシステム上のいろいろな違う場所を
28 URL のリダイレクトを行なう機能を提供する</description>
30 <sourcefile>mod_alias.c</sourcefile>
31 <identifier>alias_module</identifier>
34 <p>このモジュールのディレクティブはサーバにリクエストが到着したときに
35 URL の操作や制御をすることを可能にします。<directive
36 module="mod_alias">Alias</directive>
37 ディレクティブと <directive module="mod_alias">ScriptAlias</directive>
39 URL とファイルシステムのパスをマップするために使用されます。これは
40 <directive module="core">DocumentRoot</directive>
41 の下にないドキュメントをウェブのドキュメントツリーの一部として
42 送られるようにします。<directive module="mod_alias">ScriptAlias</directive>
43 ディレクティブにはマップ先のディレクトリが CGI
44 スクリプトのみであることを示すという追加の効果があります。
47 <p><directive module="mod_alias">Redirect</directive> ディレクティブは
49 URL に新しいリクエストを送るように指示します。これは、
50 リソースが新しい場所に移動したときによく使用されます。</p>
52 <p><module>mod_alias</module> は簡単な URL 操作向けに設計されています。
53 より複雑な操作、クエリーストリングの操作には、<module>mod_rewrite</module>
54 で提供されるツールを使用してください。</p>
58 <seealso><module>mod_rewrite</module></seealso> <seealso><a
59 href="../urlmapping.html">URL からファイルシステム上の位置へのマッピング</a></seealso>
61 <section id="order"><title>処理の順番</title>
63 <p>様々なコンテキスト中での Alias や Redirect は他のディレクティブと
64 同じように標準の <a href="../sections.html#mergin">マージ規則</a> に
65 従って処理されます。ただし、(例えば <directive type="section" module="core"
66 >VirtualHost</directive> セクションの中のように) 複数の Alias や Redirect が
67 同じコンテキスト中に現れた場合は決まった順番で処理されます。</p>
69 <p>まず、Alias の前にすべての Redirect が処理されます。ですから、<directive
70 module="mod_alias">Redirect</directive> か <directive
71 module="mod_alias">RedirectMatch</directive> にマッチするリクエストには
72 Alias は決して適用されません。次に、Alias と Redirect が設定ファイル中の
73 順番に適用され、最初にマッチしたものが優先されます。</p>
75 <p>ですから、二つ以上のディレクティブが同じパスに適用されるときは、
76 すべてのディレクティブの効果を得るためにはより詳しいパスを先に書く
77 必要があります。例えば、次の設定は期待通りの動作をします:</p>
80 Alias /foo/bar /baz<br />
84 <p>しかし、上記の二つのディレクティブの順番が逆になると、
85 <code>/foo</code> <directive module="mod_alias">Alias</directive> が
86 常に <code>/foo/bar</code> <directive
87 module="mod_alias">Alias</directive> より先にマッチしますので、後者は
94 <description>URL をファイルシステムの位置にマップする</description>
95 <syntax>Alias <var>URL-path</var>
96 <var>file-path</var>|<var>directory-path</var></syntax>
97 <contextlist><context>server config</context>
98 <context>virtual host</context>
102 <p><directive>Alias</directive> ディレクティブはドキュメントを
104 <directive module="core">DocumentRoot</directive>
106 URL の (% が復号された) パスが <var>url-path</var> で始まるものは
107 <var>directory-filename</var>
108 で始まるローカルファイルにマップされます。</p>
110 <example><title>例</title>
111 Alias /image /ftp/pub/image
114 <p>http://myserver/image/foo.gif へのリクエストに対して、サーバは
115 ファイル /ftp/pub/image/foo.gif を返します。</p>
117 <p>もし <var>url-path</var> の最後に /
118 を書いたなら、サーバがエイリアスを展開するためには、最後の /
119 が必要になることに注意してください。すなわち、<code>Alias /icons/
120 /usr/local/apache/icons/</code> というものを使用している場合は、
121 <code>/icons</code> という url はエイリアスされません。</p>
123 <p>エイリアスの<em>行き先</em>を含んでいる <directive
124 type="section" module="core">Directory</directive>
125 セクションを追加する必要があるかもしれないことに注意してください。
127 type="section" module="core">Directory</directive>
129 エイリアスの行き先の <directive
130 type="section" module="core">Directory</directive> セクションのみ
133 type="section" module="core">Location</directive>
134 セクションはエイリアスが処理される前に実行されますので、
137 <p>特に、<code>Alias</code> を
138 <directive module="core">DocumentRoot</directive>
139 ディレクトリの外側に配置した場合は、行き先のディレクトリに対する
140 アクセス権限を明示的に制限しなければならないでしょう。</p>
142 <example><title>例</title>
143 Alias /image /ftp/pub/image<br />
144 <Directory /ftp/pub/image><br />
146 Order allow,deny<br />
156 <name>AliasMatch</name>
157 <description>正規表現を使って URL をファイルシステムの位置にマップする</description>
158 <syntax>AliasMatch <var>regex</var>
159 <var>file-path</var>|<var>directory-path</var></syntax>
160 <contextlist><context>server config</context>
161 <context>virtual host</context>
165 <p>このディレクティブは <directive module="mod_alias">Alias</directive>
166 とほとんど同じですが、簡単な先頭からのマッチを行なうのではなく、
167 標準正規表現を利用します。ここで指定された正規表現と URL のパス
168 が合うかどうかを調べ、合う場合は括弧で括られたマッチを
169 与えられた文字列で置き換え、それをファイル名として使用します。たとえば、
170 <code>/icons</code> ディレクトリを使う
171 ためには以下のようなものが使用できます:</p>
174 AliasMatch ^/icons(.*) /usr/local/apache/icons$1
180 <name>Redirect</name>
181 <description>クライアントが違う URL を取得するように外部へのリダイレクトを
183 <syntax>Redirect [<var>status</var>] <var>URL-path</var>
184 <var>URL</var></syntax>
185 <contextlist><context>server config</context>
186 <context>virtual host</context>
187 <context>directory</context><context>.htaccess</context></contextlist>
188 <override>FileInfo</override>
191 <p>Redirect ディレクティブは古い URL を新しいものへマップします。
192 新しい URL がクライアントに返されます。そして、
193 クライアントは新しいアドレスをもう一回取得しようとします。
194 <var>URL-path</var> (% が復号された) パスで始まるドキュメントへの
195 すべてのリクエストは <var>URL</var> で始まる新しい
196 (% が符号化された) URL へのリダイレクトエラーが返されます。</p>
198 <example><title>例</title>
199 Redirect /service http://foo2.bar.com/service
202 <p>クライアントは http://myserver/service/foo.txt
203 へのリクエストを行なうと、代わりに http://foo2.bar.com/service/foo.txt
204 をアクセスするように告げられます。</p>
206 <note><title>注意</title><p>設定ファイル中の順番に関わらず、
207 Redirect 系のディレクティブは Alias
208 ディレクティブと ScriptAlias ディレクティブよりも優先されます。
209 また、.htaccess ファイルや <directive
210 type="section" module="core">Directory</directive>
211 セクションの中で使われていたとしても、<var>URL-path</var>
212 は相対パスではなく、完全な URL でなければなりません。</p></note>
214 <p>もし <var>status</var> 引数が与えられていなければ、リダイレクトは
215 "temporary" (HTTP ステータス 302) になります。これはクライアントに
216 リソースが一時的に移動したということを示します。<var>Status</var>
217 引数は 他の HTTP のステータスコードを返すために使用することができます:</p>
222 <dd>永久にリダイレクトをするステータス (301) を返します。
223 これはリソースが永久に移動したということを意味します。</dd>
227 <dd>一時的なリダイレクトステータス (302)
228 を返します。これがデフォルトです。</dd>
232 <dd>"See Other" ステータス (303) を返します。
233 これはリソースが他のもので置き換えられたことを意味します。</dd>
237 <dd>"Gone" ステータス (410) を返します。これはリソースが永久に
238 削除されたことを意味します。このステータスが使用された場合、
239 <var>url</var> 引数は省略されなければなりません。</dd>
242 <p><var>Status</var> の値にステータスコードを数値で与えることで
243 他のステータスコードも返すことができます。ステータスが 300 と 399
244 の間にある場合、<var>url</var> 引数は存在していなければいけません。
245 その他の場合は省略されていなければなりません。ただし、
246 ステータスは Apache のコードが知っているものである必要があります
247 (http_protocol.c の関数 <code>send_error_response</code>
251 <example><title>例</title>
252 Redirect permanent /one http://example.com/two<br />
253 Redirect 303 /three http://example.com/other
260 <name>RedirectMatch</name>
261 <description>現在の URL への正規表現のマッチにより
262 外部へのリダイレクトを送る</description>
263 <syntax>RedirectMatch [<var>status</var>] <var>regex</var>
264 <var>URL</var></syntax>
265 <contextlist><context>server config</context>
266 <context>virtual host</context>
267 <context>directory</context><context>.htaccess</context></contextlist>
268 <override>FileInfo</override>
271 <p>このディレクティブは <directive module="mod_alias">Redirect</directive>
272 とほとんど同じですが、簡単な先頭からのマッチを行なうのではなく、
273 標準正規表現を利用します。ここで指定された正規表現と URL-path
274 が合うかどうかを調べ、合う場合は括弧で括られたマッチを
275 与えられた文字列で置き換え、それをファイル名として使用します。
276 たとえば、すべての GIF ファイルを別サーバの同様な名前の JPEG
277 ファイルにリダイレクトするには、以下のようなものを使います:
281 RedirectMatch (.*)\.gif$ http://www.anotherserver.com$1.jpg
287 <name>RedirectTemp</name>
288 <description>クライアントが違う URL を取得するように外部への一時的な
289 リダイレクトを送る</description>
290 <syntax>RedirectTemp <var>URL-path</var> <var>URL</var></syntax>
291 <contextlist><context>server config</context>
292 <context>virtual host</context>
293 <context>directory</context><context>.htaccess</context></contextlist>
294 <override>FileInfo</override>
297 <p>このディレクティブはクライアントに Redirect
298 が一時的なものである (ステータス 302) ことを知らせます。
299 <code>Redirect temp</code> とまったく同じです。</p>
304 <name>RedirectPermanent</name>
305 <description>クライアントが違う URL を取得するように外部への永久的な
306 リダイレクトを送る</description>
307 <syntax>RedirectPermanent <var>URL-path</var> <var>URL</var></syntax>
308 <contextlist><context>server config</context>
309 <context>virtual host</context>
310 <context>directory</context><context>.htaccess</context></contextlist>
311 <override>FileInfo</override>
314 <p>このディレクティブはクライアントに Redirect が永久的なもの
315 (ステータス 301) であることを知らせます。
316 <code>Redirect permanent</code> とまったく同じです。</p>
321 <name>ScriptAlias</name>
322 <description>URL をファイルシステムの位置へマップし、マップ先を
323 CGI スクリプトに指定</description>
324 <syntax>ScriptAlias <var>URL-path</var>
325 <var>file-path</var>|<var>directory-path</var></syntax>
326 <contextlist><context>server config</context>
327 <context>virtual host</context>
331 <p><directive>ScriptAlias</directive> ディレクティブは、対象ディレクトリに
332 <module>mod_cgi</module> の cgi-script
335 <directive module="mod_alias">Alias</directive>
337 URL の (% が復号された) パスが <var>URL-path</var> で始まるものは
339 フルパスである二番目の引数にマップされます。</p>
341 <example><title>例</title>
342 ScriptAlias /cgi-bin/ /web/cgi-bin/
345 <p><code>http://myserver/cgi-bin/foo</code>
347 <code>/web/cgi-bin/foo</code> を実行します。</p>
352 <name>ScriptAliasMatch</name>
353 <description>URL を正規表現を使ってファイルシステムの位置へマップし、マップ先を
354 CGI スクリプトに指定</description>
355 <syntax>ScriptAliasMatch <var>regex</var>
356 <var>file-path</var>|<var>directory-path</var></syntax>
357 <contextlist><context>server config</context>
358 <context>virtual host</context>
362 <p>このディレクティブは <directive module="mod_alias">ScriptAlias</directive>
363 とほとんど同じですが、簡単な先頭からのマッチを行なうのではなく、
364 標準正規表現を利用します。ここで指定された正規表現と URL-path
365 が合うかどうかを調べ、合う場合は括弧で括られたマッチを
366 与えられた文字列で置き換え、それをファイル名として使用します。
367 たとえば、標準の <code>/cgi-bin</code>
368 を使用するようにするためには、以下のようなものを使います:
372 ScriptAliasMatch ^/cgi-bin(.*) /usr/local/apache/cgi-bin$1