<-
Apache > HTTP Server > Documentation > Version 2.4

ӛ r

݋b _ _ Ɯ”. ٿ ~@ ݋ O[.

rH b Cb ݋L ü ~ǰų, Ưr 丮, H, xzh, URL ~ ] . ݋b ٸ C ~ Ѹ[ r ӛƳ .htaccess H@ ȝ~[b Ҏ^@ Ѵ.

Support Apache!

O

top

r ӛ v

ӛb ΰ v . κл@ ſ] Qȴ. ش[b ] ȿ ` C ~Ѵ. ^, <IfDefine> <IfModule>@ ݋L CV V QѴ. CV ° ƔR ȿ b C ] ~ȴ. ”R ȿ b Cb CѴ.

<IfDefine> Cb httpd w࿡ HͰ b 쿡 ȿ ` C ~Ѵ. ٞ r@ R, ݋L httpd -DClosedForNow C 쿡 ] ٸ ȝh ٓƷӛȴ:

<IfDefine ClosedForNow>
Redirect / http://otherserver.example.com/
</IfDefine>

<IfModule> Cn Ưr ݋L ` 쿡 ȿ C ~Ѵپb @ ܸ[Ob ſ 񔇸[. @ ݋L rڷ Hϸ[ų ڷ H rH տ LoadModule R Ѵ. Cb Ưr ġϞ rHϓ ٸ ʿ䰡 @V ȝ~ؾ Ѵ. ^b Ϟ~ 얓 @ ] V얿 ȝ~[ [b C ȿ ΔR ȵȴ.

ٞ ݋ mod_mime_magic @V MimeMagicFiles C QѴ.

<IfModule mod_mime_magic.c>
MimeMagicFile conf/magic
</IfModule>

<IfDefine> <IfModule> ȝ տ "!"@ ٿ @ _ڷ ] . , \ ӛ@ ݋ ȝ~[ ȿ @ ] .

top

HϳCz۰

ȝ~Ǿb r ӛ@ HϳCz۰ (webspace) Ưr ҿ r@ [b ͵ƴ. v mƸ ظ[b ͓ ߿[. HϳCzۻ@ ü 忡݋ zr b ƴ. 齁, ⺻@ڷ Hġ ġ [R Ϟ[z HϳCz /usr/local/apache2, Un HϳCz "c:/Program Files/Apache Group/Apache2" ġȴ. (Hġb Un݋ m H, _E{ Ƈ, E{ ȝ~`@ Ǹ[.) ^ @ ݋L [O Ŭƾh Ե ȝh ƴ. E݋ Ϟ[z݋ ⺻ Hġ ġ /dir/@ HϳCz /usr/local/apache2/htdocs/dir/ شѴ. @ Γtz ݋ ڷ e ] V얿 ^C HϳCzۿ [ ʿb ^.

HϳCz ӛ

<Directory> <Files> C rFe@ ȝ~[b Cb HϳCz Ưr κп C ~Ѵ. <Directory> C ` C@ r HϳCz 丮 [ 丮 ~ȴ. .htaccess H@ ȝ~ؙn b . ٞ r@ R, 丮 U(index) /var/web/dir1 Ƹ[ 丮݋ 丮 U(index) ɸ[.

<Directory /var/web/dir1>
Options +Indexes
</Directory>

<Files> ӛ ` C@ 丮 b ^ r Ɠ@ HϿ ~ȴ. rH ּrκп b ٞ r@ R, ҿ ^ private.htmlƶ Ɠ@ H @ źѴ.

<Files private.html>
Order allow,deny
Deny from all
</Files>

HϳCz Ưr κп b H@ Ī[ <Files> <Directory> ӛ@ ȝ~Ѵ. ٞ r@ R, /var/web/dir1/private.html, /var/web/dir1/subdir2/private.html, /var/web/dir1/subdir3/private.html /var/web/dir1/ 丮 E b Ɠ private.html H @ źѴ.

<Directory /var/web/dir1>
<Files private.html>
Order allow,deny
Deny from all
</Files>
</Directory>

ӛ

<Location> C ƿ ش[b rFe@ ȝ~[b Cb ^ Ưr r@ ٲ۴. ٞ r@ R, /privateڷ C۸[b URL- ٓ źεȴ. ⿡b http://yoursite.example.com/private, http://yoursite.example.com/private123, http://yoursite.example.com/private/dir/file.html /private ڄP C۸[b ] شȴ.

<Location /private>
Order Allow,Deny
Deny from all
</Location>

<Location> Cb HϳCzۿ [ ʿ䰡 ^. ٞ b Ưr URL@ mod_status [b Hġ ڵ\ [CŰb ش. HϳCzۿ server-statusb Hϻ@ ʿ^.

<Location /server-status>
SetHandler server-status
</Location>

ϵī rFe

<Directory>, <Files>, <Location> C݋ C F Hƺ\ fnmatch @ ݋ ȝ~[b ϵī ڸ ȝ~ ] . "*" ھb ڄPƶn tO, "?" ھb Ѱ t, "[seq]"b seq ߿ ڸ t. ϵīn "/" ڸ tb oѴ. E݋ ھb ȝ~ؾ Ѵ.

Ϟ r ʿ[R perlxȯ rFe@ ȝ~[b <DirectoryMatch>, <FilesMatch>, <LocationMatch> ȝ~ ] . ׵\ E r J ݋ rFe ӛ@ ȝ~[R C ~Ǿb Ҏ^ [b .

ȝ~ 丮 r@ [b rFe ϵī ӛ@ ٞ :

<Directory /home/*/public_html>
Options Indexes
</Directory>

rFe ӛ@ ȝ~[ 偿 \ v ׸HϿ @ ź ] :

<FilesMatch \.(?i:gif|jpe?g|png)$>
Order allow,deny
Deny from all
</FilesMatch>

@ ȝ~[

HϳCz ӛ ӛ [ ø[b ͻ@ ſ . HϳCzۿ b ü C ~Vb H <Directory> <Files> ȝ~Ѵ. (Γtz݋ e ) HϳCzۿ ʾb ü C ~Vb <Location>@ ȝ~Ѵ.

HϳCzۿ b ü @ Ѹ[ <Location>@ ȝ~[R ȵȴ. \ ٸ (URL) @ HϳCz ҿ [ ] ڹǷ, ɽ @ ȸ ] V얓ƴ. ٞ r 캸:

<Location /dir/>
Order allow,deny
Deny from all
</Location>

r@ http://yoursite.example.com/dir/@ ]ѴٔR ۵Ѵ. ׵\ ڸ 亰[ʾb HϳCz@ ȝ~ѴٔR Եdz? http://yoursite.example.com/DIR/@ ][ @ ȸ ] . ^ <Directory> Cb ][b ^ ҿ݋ ݋zǾb ~ ~ȴ. (ܾb HϳCz r ȝ~[b . Ur ȝ~[ 丮 HϳCz \ ҿ ] . <Directory> Cb Ur 󰣴. ׵\Ƿ @ ] @ ݋b Options C ȝ~[ Ur Cؾ Ѵ.)

Ƹn _@ ڸ 亰[b HϳCz@ ȝ~[Ƿ Ʒ ϓ Ͻ ʾbٽO en 𸥴. ׵\ ٸ Ҏ^ڷΙn \ ġ HϳCz ġ [ ] @ [. E݋ ɸ[R H HϳCz ӛ@ ȝ~ؾ Ѵ. ׵\ Ģ ܰ [ . r @ <Location /> ӛ ΔR ӛ Ưr URL Ƈ ] ~ǹǷ Ϻ[ [.

top

xzh

<VirtualHost> ӛ@ Ưr xzh ~Ǿb C@ `Ѵ. ƾb ǻͿ݋ ٸ r@ ȝ~ \ xzh ݋zV Ϟ~[. ڼ rb xzh ݋ O[.

top

UC

<Proxy> <ProxyMatch> ӛ@ r URL mod_proxy UC ݋L ٸ[b 쿡 ~ȴ. ٞ r@ R, UC ݋L cnn.com ȝh ] ^.

<Proxy http://cnn.com/*>
Order allow,deny
Deny from all
</Proxy>

top

ȿ C ȝ~ ] ?

r ӛȿ ȝ~ ] b C ˷R C ȝ~ Ȯθ[. <Directory>݋ ȝ~ Cb <DirectoryMatch>, <Files>, <FilesMatch>, <Location>, <LocationMatch>, <Proxy>, <ProxyMatch> ӛ݋n ȝ~ɸ[. ׵\, ܰ :

top

ӛ J[b Ҏ^

r ӛ@ ſ Ư Ҏ^ڷ ~ȴ. b݋ r C ؼ[b Ҏ^ ߿ @ ֱV얿 Ҏ^@ ظ[b ͓ ߿[.

J[b b݋b:

  1. (rFe@ ȝ~[ʾb) <Directory> .htaccessb C Ͻ (쿡 .htaccess <Directory> C[nU r ] )
  2. <DirectoryMatch> (׸O <Directory ~>)
  3. <Files> <FilesMatch>b C Ͻ
  4. <Location> <LocationMatch>b C Ͻ

<Directory> ܸ[O ӛ@ rHϿ b݋ Qȴ. ( b݋ 1) <Directory>b 丮 ~ ª@ Ϳ݋ ׃ʙڷ Qȴ. E݋ 齁, <Directory /var/web/dir>@ <Directory /var/web/dir/subdir> QѴ. @ 丮 Ī[b \ <Directory> ӛ ٔR Ƶ@ rH b݋ QѴ. Include C ` r@ Include C ġ ` H ~ b Q QѴ.

<VirtualHost> ӛ ȿ ` ӛ@ xzh r ^ b ش ӛ ~ȴ. E݋ xzh ȿ݋ ݋L rȝH@ ]r ] .

mod_proxy ] ݋zV, <Proxy> ӛ Qb݋b <Directory> ӛ .

ٞ b ӛ@ ӛ ]rѴ.

v

<Location>/<LocationMatch>b (Aliases DocumentRoot ȝ~[ URL@ Hϸڷ ȯ[b) Ɠ_ Z Qȴ. _ b CѴ.

ٞ@ J[b b݋ [b . Ƶ ] ~ȴٽO r[R Cb A > B > C > D > E b݋ Qȴ.

<Location />
E
</Location>

<Files f.html>
D
</Files>

<VirtualHost *>
<Directory /a/b>
B
</Directory>
</VirtualHost>

<DirectoryMatch "^.*b$">
C
</DirectoryMatch>

<Directory /a/b>
A
</Directory>

b ٞ . <Location> ӛ@ ߿ Q[Ƿ <Directory> ӛ b Ѱ ^ ݋L @ ɸ[. , J[b b݋b ߿[Ƿ Ǹ[!

<Location />
Order deny,allow
Allow from all
</Location>

# ! <Directory> ӛ@ ƹ ȿ ^
<Directory />
Order allow,deny
Allow from all
Deny from badguy.example.com
</Directory>

:  en  |  fr  |  ja  |  ko  |  tr 

top

Comments

Notice:
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 mailing lists.
С͸