Apache > HTTP Server > Documentation > Version 2.4 > How-To / Tutorials

Hġ 丮: .htaccess H

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

.htaccess H@ ȝ~[ 丮 r@ ] .

Support Apache!



.htaccess H


Ƹ/ ȝ~[b

.htaccess H(Ȥ@ "л rH")@ ȝ~[R 丮 r@ ] . \ r C b H@ Ưr ݋ 丮 ΔR, 丮 [丮 C ~Ѵ.


.htaccess Hϸ@ ٸ ȝ~[O ʹٔR, AccessFileName C ȝ~[ ] . 齁, .config Hϸ@ ȝ~[R ݋L rHϿ ٞ ߰Ѵ.

AccessFileName .config

.htaccess Hϻ@ ּrH ^ . AllowOverride C HϿ ] b ~@ rѴ. Cb .htaccess HϿ݋ A~[b C з rѴ. C .htaccess HϿ݋ ȝ~ ] ٔR, ش C ݋ Override H@ C A~[ AllowOverride ȝ~ @@ ˷ش.

齁, AddDefaultCharset C ݋ R C .htaccess HϿ݋ ȝ~ ] . (C ࿡݋ ȝ~ H@ .) Override R FileInfo . E݋ C .htaccess HϿ݋ ȝ~[݋b AllowOverride FileInfo ʿ[.


ȝ~: ݋Lr, xzh, directory, .htaccess
Override: FileInfo

Ưr C .htaccess HϿ݋ ȝ~ ] b ñݸ[R C ݋ ȝ~ H ".htaccess" b ȮѴ.


.htaccess H@ ȝ~[ (Ȥ@ ȝ~[ ʳ)

^ڷ ݋LHϿ ] ^b 찡 ”R .htaccess H@ ȝ~[R ȵȴ. 齁, ȝ~ ΄ H .htaccess HϿ Ѵپb ͻ@ ߽o ˷ ش. ƾb ȝǓ ”. ݋Lr ȝ~ ΄ r@ @ ] O, ȝ Ƶ\ Ѵ.

.htaccess Hϻ@ ڰ 丮 ݋L r@ ٸԸ[O ݋L Czۿ root ѓ ^b 쿡 ȝ~Ѵ. ݋L ڰ r@ [O ʻ@ ^ ȝ~ڰ .htaccess H@ ]r[nU A~[b ͓ ٶ[. 齁, ǻͿ \ ȝ~ ȝh ݋z[b ISP݋ ȝ~ڰ _ r@ [O ͻ@ 찡 ׵\[.

׵\ ^ڷ .htaccess Hϻ@ ؾ Ѵ. .htaccess HϿ݋ A~[b Cb ּrH <Directory> ӛ @ ȿ .

ٞ ΰ ū ϞV얿 .htaccess H ȝ~@ ؾ Ѵ.

ù偓b ɓƴ. AllowOverride .htaccess H@ ȝ~[nU A~[R, Hġb 丮 .htaccess H@ ãb. E݋ .htaccess H@ A~[R H@ ȝ~[ ʾb 쿡n ɓ ! , .htaccess Hϻ@ ݋ ]V нδ.

Դٰ ~ؾ [b ü C ڱ Hġb 丮݋ .htaccess H@ ãb. ( C ~[ @ O.) E݋ /www/htdocs/example 丮 b H@ ][R, Hġb ٞ Hϵ@ ãƾ Ѵ.


E݋ 丮 b H@ V rHϓ ^n HϳCz@ 4 ؾ Ѵ. (/݋n .htaccess H@ A~ 츦 Ѵ. @ A~[ ʾb.)

偓 Ϟb ȓƴ. ȝ~ڿ ݋Lr @ ֔R _ } ] ^b ȭ Ͻ ] . ȝ~ڿ Ʒ @ R e[. , ȝ~ڰ [b ͺ @ @ ֔R v] 齁´. ȝ~ڿ ]@ Ȯ ˷. ȝ~ڿ AllowOverride r[b rȮ ˸O L ݋ [R ՙڷ ȥ@ ] .

C /www/htdocs/example.htaccess H@ ξb Ͱ ݋Lr <Directory /www/htdocs/example> Directory r ξb ͻ@ .

/www/htdocs/example b .htaccess ӛ:

/www/htdocs/example b .htaccess H ~

AddType text/example .exm

apache2.conf HϿ b ӛ

<Directory /www/htdocs/example>
AddType text/example .exm

׵\ H@ ] V r@ ʽO Hġ CV 偸 r@ бV얿 @ r@ ݋LrHϿ ȝ~[R ɓ .

AllowOverride C noneڷ r[R .htaccess H@ ȝ~ ] ^.

AllowOverride None


C ~[

.htaccess H@ T 丮 丮 [丮 .htaccess HϿ b r C ~Ѵ. E݋ 丮 .htaccess H@ ؾ Ѵ. T b݋ C ~Ѵ. Ưr 丮 b .htaccess Hϻ@ 丮 b .htaccess H C ȿ ] O, 丮 b Cb 丮 Ȥ@ ּrHϿ b C ȿ ] .


/www/htdocs/example1 丮 ٞ @ .htaccess Hϓ .

Options +ExecCGI

(: .htaccess HϿ "Options" C ȝ~[R "AllowOverride Options" ʿ[.)

/www/htdocs/example1/example2 丮b ٞ @ .htaccess Hϓ .

Options Includes

.htaccess H Options Includes r@ ȿ V얿 /www/htdocs/example1/example2 丮b CGI @ A~[ ʾb.



΄ Ҏ^@ ˱ ٷ ^ оbٔR ͓ . x ΄@ [R .htaccess Hϓ ʿ[پb ذ θ . ƾb ȝǓ ”. ּrH <Directory> ӛ ΄ C ξb ͓ [b Ҏ^ƽO, ݋L ּrH@ ]r ] ^b 쿡 .htaccess H@ ȝ~ؾ Ѵ. .htaccess H@ ȝ~ؾ [b ȝ~[ ƾ [bb ݋ [.

տ݋ n .htaccess Hϓ ʿ[ٽO eǔR E r n ͓ƴ.

.htaccess H ~.

AuthType Basic
AuthName "Password Required"
AuthUserFile /www/passwords/password.file
AuthGroupFile /www/passwords/group.file
Require Group admins

C ۸[݋b AllowOverride AuthConfig C ʿ`@ U[.

΄ Ѻο ڼ @ ΄ 丮@ ٶ.


Server Side Includes

Ǵٸ ^ .htaccess H ~nb Ưr 丮݋ Server Side Includes ɸ[ b ͓ƴ. [b 丮 .htaccess HϿ ٞ @ r C ȝ~[R ȴ.

Options +Includes
AddType text/html shtml
AddHandler server-parsed shtml

C ۸[R AllowOverride Options AllowOverride FileInfo ʿ`@ U[.

server-side includes ڼ @ SSI 丮@ ٶ.



ڷ .htaccess H@ ȝ~[ Ưr 丮݋ CGI α׷ @ A~[O ʹٔR, ٞ @ r@ ȝ~Ѵ.

Options +ExecCGI
AddHandler cgi-script cgi pl

Ȥ@ 丮 b H@ CGI α׷ڷ Q[O ʹٔR ٞ @ rn ɸ[.

Options +ExecCGI
SetHandler cgi-script

C ۸[R AllowOverride Options AllowOverride FileInfo ʿ`@ U[.

CGI αEְ r ڼ @ CGI 丮@ ٶ.



.htaccess HϿ r C [b @ [ ʾb \ Ϟ @ ] .

^ b r C ɸ[ b AllowOverride r[ ʻ@ . Ǿb H _ AllowOverride None ^b ȮѴ. .htaccess H@ ƹԳ @ ٞ ٳC ٸ[ ȝغ ] . ݋L ʙڔR ȮǞ AllowOverride None@ ȝ~ .

^ ݋ V ݋L Te[R Hġ α׸ . Ƹn .htaccess HϿ b C A~[ ʾbٽO ͓ƴ. ”O ^ ٔR Oģ.

:  en  |  es  |  fr  |  ja  |  ko  |  pt-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 mailing lists.