Alias 指令

說明 映射URL到文件系統的特定區域
語法 Alias URL-pathfile-path|directory-path
作用域 server config, virtual host
狀態 基本(B)
模塊 mod_alias

Alias指令使文檔可以被存儲在DocumentRoot以外的本地文件系統中。以(%已解碼的)url-path路徑開頭的URL可以被映射到以directory-path開頭的本地文件。

示例:

Alias /image /ftp/pub/image

對"http://myserver/image/foo.gif"的請求,服務器將返回"/ftp/pub/image/foo.gif"文件。因為僅匹配完整路徑,所以上述例子不會匹配對"http://myserver/imagefoo.gif"的請求。對于使用正則表達式的匹配,請參見AliasMatch指令。

注意:如果url-path中有后綴"/",則服務器要求有后綴"/"以擴展此別名。也就是說"Alias /icons/ /usr/local/apache/icons/"并不能對"/icons"實現別名。

注意,可能需要額外指定一個<Directory>段來覆蓋別名的最終對象。由于只有出現在<Directory>段之前的別名才會被檢測,所以它只對最終對象生效。(由于執行別名操作之前<Location>段會被首先掃描一次,所以它們也是有效的)

特別地,如果對在DocumentRoot之外的某個目錄建立了一個Alias ,則可能需要明確的對目標目錄設定訪問權限。

示例:

Alias /image /ftp/pub/image
<Directory /ftp/pub/image>
Order allow,deny
Allow from all
</Directory>

?1 < IfModule? alias_module >
?2 ????#
?3 ????#?Redirect:?Allows?you?to?tell?clients?about?documents?that?used?to?
?4 ????#?exist?in?your?server's?namespace,?but?do?not?anymore.?The?client?
?5 ????#?will?make?a?new?request?for?the?document?at?its?new?location.
?6 ????#?Example:
?7 ????#?Redirect?permanent?/foo?http://test.piao.net/bar
?8
?9 ????#
10 ????#?Alias:?Maps?web?paths?into?filesystem?paths?and?is?used?to
11 ????#?access?content?that?does?not?live?under?the?DocumentRoot.
12 ????#?Example:
13 ????#?Alias?/webpath?/full/filesystem/path
14 ????Alias?/THINKPHP???D:/ThinkPHP?
15 ????#
16 ????#?If?you?include?a?trailing?/?on?/webpath?then?the?server?will
17 ????#?require?it?to?be?present?in?the?URL.??You?will?also?likely
18 ????#?need?to?provide?a? < Directory > ?section?to?allow?access?to
19 ????#?the?filesystem?path.
20
21 ????#
22 ????#?ScriptAlias:?This?controls?which?directories?contain?server?scripts.?
23 ????#?ScriptAliases?are?essentially?the?same?as?Aliases,?except?that
24 ????#?documents?in?the?target?directory?are?treated?as?applications?and
25 ????#?run?by?the?server?when?requested?rather?than?as?documents?sent?to?the
26 ????#?client.??The?same?rules?about?trailing?"/"?apply?to?ScriptAlias
27 ????#?directives?as?to?Alias.
28 ????#
29 ????ScriptAlias?/cgi-bin/?"D:/Program?Files/Apache2.2/cgi-bin/"
30
31 </ IfModule >
?1 #
?2 #?"D:/Program?Files/Apache2.2/cgi-bin"?should?be?changed?to?whatever?your?ScriptAliased
?3 #?CGI?directory?exists,?if?you?have?that?configured.
?4 #
?5 < Directory? "D:/Program?Files/Apache2.2/cgi-bin" >
?6 ????AllowOverride?None
?7 ????Options?None
?8 ????Order?allow,deny
?9 ????Allow?from?all
10 </ Directory >
11
12 < Directory? "D:/ThinkPHP" >
13 ????AllowOverride?None
14 ????Options?None
15 ????Order?allow,deny
16 ????Allow?from?all
17 </ Directory >
18 #