{"id":100,"date":"2007-07-02T09:36:00","date_gmt":"2007-07-02T01:36:00","guid":{"rendered":"http:\/\/learn-house.idv.tw\/?p=100"},"modified":"2010-01-17T19:03:31","modified_gmt":"2010-01-17T11:03:31","slug":"htaccess-%e7%b0%a1%e4%bb%8b%e8%88%87%e5%b8%b8%e7%94%a8%e5%8a%9f%e8%83%bd","status":"publish","type":"post","link":"https:\/\/learn-house.idv.tw\/?p=100","title":{"rendered":".htaccess \u7c21\u4ecb\u8207\u5e38\u7528\u529f\u80fd"},"content":{"rendered":"<p>\u4ee5\u4e0b\u5167\u5bb9\u662f\u8f49\u8cbc\u65bc\u6211\u7684\u820a\u90e8\u843d\u683c\u4e2d\u7684\u4e00\u7bc7\u6587\u7ae0<\/p>\n<p>\u8cc7\u6599\u4f86\u6e90<a href=\"http:\/\/dob.tnc.edu.tw\/themes\/old\/showPage.php?s=622&amp;t=79\" target=\"_blank\">\u7db2\u7ad9\u5efa\u7f6e\u767e\u5bf6\u7bb1 <\/a><\/p>\n<p>\u525b\u597d\u6700\u8fd1\u9047\u5230\u4e00\u9ede\u985e\u4f3c\u7684\u554f\u984c\uff0c\u56e0\u6b64\u5c31\u8cbc\u51fa\u4f86\u548c\u5927\u5bb6\u4e00\u8d77\u5206\u4eab&nbsp;<\/p>\n<p>.htaccess \u6a94\u662f acache http \u4f3a\u670d\u5668\u4e0a\u7684\u4e00\u500b\u8a2d\u5b9a\u6a94\u3002<br \/> \u4e00\u822c\u4f86\u8aaa\uff0c\u7ba1\u7406\u4eba\u54e1\u90fd\u6703\u958b\u653e\u90e8\u4efd\u529f\u80fd\u7d66\u4f60\u81ea\u884c\u8a2d\u5b9a\uff0c\u4e5f\u6709\u7684\u6703\u5b8c\u5168\u95dc\u9589\u5c0d .htaccess \u7684\u652f\u63f4\u3002<\/p>\n<ol>\n<li>\u8a2d\u5b9a\u7db2\u9801\u5bc6\u78bc\uff1b<\/li>\n<li>\u8a2d\u5b9a\u767c\u751f\u932f\u8aa4\u6642\u51fa\u73fe\u7684\u6587\u4ef6\uff1b<\/li>\n<li>\u6539\u8b8a\u9996\u9801\u7684\u6a94\u6848 (index.html)\uff1b<\/li>\n<li>\u7981\u6b62\u8b80\u53d6\u6a94\u6848\uff1b<\/li>\n<li>\u91cd\u65b0\u5c0e\u5411\u6587\u4ef6\uff1b<\/li>\n<li>\u52a0\u4e0a MIME \u985e\u5225\uff1b<\/li>\n<li>\u9632\u6b62\u5217\u51fa\u76ee\u7da0\u5167\u7684\u6a94\u6848..\u7b49\u7b49<\/li>\n<\/ol>\n<p>\u5176\u5be6\u9084\u6709\u5f88\u591a\u529f\u80fd\uff0c\u4e0d\u904e\u4e00\u822c\u53ea\u6703\u958b\u653e\u4e00\u822c\u529f\u80fd\u7d66\u4f60\u7528 (\u9664\u975e\u4f60\u662f\u7ba1\u7406\u54e1&#8230;)\uff0c\u800c\u6211\u4e5f\u4e0d\u8b58\u90a3\u9ebc\u591a\u3002\u6240\u4ee5\u6211\u53ea\u8aaa\u4e00\u822c\u6703\u7528\u5230\u7684\u529f\u80fd\u3002<\/p>\n<p><strong><font color=\"#0000ff\">\u3010.htaccess \u7c21\u4ecb \u3011<\/font><\/strong><\/p>\n<p><font><\/font><font style=\"line-height: 200%\">.htaccess \u662f\u4e00\u500b\u6587\u5b57\u6a94\uff0c\u4f60\u53ef\u4ee5\u505a\u4efb\u4f55\u597d\u50cf notepad \u7684\u6587\u5b57\u7de8\u8f2f\u5668\u53bb\u5beb\u4e00\u500b\u3002<br \/> \u6216\u8005\u4f60\u6703\u5c0d .htaccess \u9019\u500b\u540d\u5b57\u6709\u9ede\u56f0\u60d1\uff0c\u5176\u5be6 .htaccess \u662f\u4e00\u500b\u5b8c\u5168\u7684\u6a94\u6848\u540d\uff0c \u4e0d\u662f filaname.htaccess \u6216\u8005\u751a\u9ebc\u7684\uff08\u7576\u7136\u4e5f\u6709\u7ba1\u7406\u54e1\u6545\u610f\u628a\u5b83\u8a2d\u5b9a\u6210\u5176\u4ed6\u540d\u5b57\uff0c\u4f46\u4e00\u822c\u90fd\u662f\u7528 .htaccess \u7684\uff09\u3002 \u70ba\u4f55\u662f .htaccess\uff1f\u56e0\u70ba\u6240\u6709\u4ee5 &quot;.&quot; \u958b\u982d\u7684\u6a94\u540d\u5728 *nix \u7cfb\u7d71\u4e2d\u4e5f\u662f\u6709\u5c6c\u6027\u96b1\u85cf\u7684\uff0c\u5e73\u5e38\u5217\u51fa\u8cc7\u6599\u593e\u6642\u4e0d\u6703\u51fa\u73fe\uff0c\u6240\u4ee5\u4fdd\u5b89\u6703\u597d\u4e00\u9ede\u3002 \u4f60\u53ef\u80fd\u6703\u554f\uff1a<strong>\u300eMS Windows \u8981\u6211\u4e00\u5b9a\u7d66\u5b83\u4e00\u500b\u540d\u5b57\uff0c\u5982\u4f55\u628a\u5b83\u5b58\u6a94\u6210\u70ba .htaccess\uff1f\u300f<\/strong> \u5176\u5be6\u65b9\u6cd5\u6709\u5169\u500b\u3002 \u7b2c\u4e00\u500b\u662f\u5230 ms-dos \u7684\u8996\u7a97\u4e2d\uff0c\u6309 <strong>ren filename.xxx  .htaccess<\/strong> \u5c31\u53ef\u4ee5\u4e86\uff1b\u7b2c\u4e8c\u500b\u662f\u5728\u4e0a\u50b3\u5230\u4f3a\u670d\u5668\u6642\u624d\u6539\u540d\u505a .htaccess\u3002<br \/> \u800c .htaccss \u5167\u8a2d\u5b9a\u7684\u683c\u5f0f\u662f\u4e00\u884c\u4e00\u500b\u6307\u4ee4\uff0c\u5982\u679c\u4f60\u7684 notepad \u8a2d\u5b9a\u4e86\u81ea\u52d5\u63db\u884c\u7684\u8a71\uff0c\u8acb\u95dc\u4e0a\u5b83\uff0c\u9019\u6a23\u6703\u6bd4\u8f03\u5b89\u5168\u3002<br \/> \u4e00\u9ede\u8981\u6ce8\u610f\uff0c .htaccess \u662f apache \u7684\u7522\u7269\uff0c\u4e0d\u662f IIS \u7684\u3002IIS \u4f3a\u670d\u5668\u4e0d\u652f\u63f4\u5b83\uff0c\u4e5f\u5c31\u662f\u8aaa\u4f60\u4e0d\u80fd\u4ee5\u7c21\u55ae\u5730\u4e0a\u50b3\u4e00\u500b ASCII \u6a94\u53bb\u8a2d\u5b9a\u5728 IIS \u4f3a\u670d\u5668\u4e0a\u7684 http \u670d\u52d9\u3002<br \/> \u5728\u4e0a\u8f09 .htaccess \u6642\uff0c<strong>\u5fc5\u9700\u4f7f\u7528 ASCII \u6a21\u5f0f\uff01<\/strong>\u4f60\u6216\u8a31\u9084\u8981 chmod \u5b83\u5230 644(RW_R__R_)\u3002<br \/> \u6bcf\u4e00\u500b\u653e\u4e86 .htaccess \u7684\u76ee\u9304\u548c\u5b83\u7684\u5b50\u76ee\u9304\u90fd\u6703\u88ab .htaccess \u5f71\u97ff\u3002\u5982\u679c\u6211\u5728 \/abc\/ \u653e\u4e86\u4e00\u500b .htaccess\uff0c\u90a3\u9ebc \/abc\/ \u548c \/abc\/def\/ \u5167\u6240\u6709 file \u90fd\u6703\u88ab\u5b83\u5f71\u97ff\uff0c\u4f46 \/index.html \u4e0d\u6703\u88ab\u5b83\u5f71\u97ff &larr;&larr; \u9019\u4e00\u9ede\u662f\u5f88\u91cd\u8981\u7684\u3002<\/font><\/p>\n<p><strong><font color=\"#0000ff\">\u3010\u5bc6\u78bc\u4fdd\u8b77 \u3011<\/font><\/strong><\/p>\n<p><font style=\"line-height: 200%\">\u9019\u662f\u6700\u5e38\u898b .htaccess \u88ab\u4f7f\u7528\u7684\u529f\u80fd\u4e4b\u4e00\uff0c\u8cc7\u6599\u593e\u5bc6\u78bc\u4fdd\u8b77\u3002<br \/> \u9019\u7a2e\u65b9\u6cd5\u53ef\u4ee5\u4f7f\u6c92\u6709\u6388\u6b0a\u7684\u700f\u89bd\u8005\u4e0d\u80fd\u9032\u5165\u4f60\u6240\u8a2d\u5b9a\u7684\u9650\u5236\u5340\u57df\uff0c\u4f7f\u7528\u4e86 Javacript \u8a2d\u7684\u5bc6\u78bc\u592a\u7c21\u55ae\u4e86\uff0c\u4e00\u4e0b\u5b57\u5c31\u6703\u88ab\u7834\u89e3\uff0c\u800c\u4f7f\u7528 .htaccess \u7cfb\u7d71\u5c31\u6bd4\u4f7f\u7528 CGI \u7a0b\u5f0f\u4fdd\u8b77\u6703\u54e1\u5c08\u9801\u5c07\u66f4\u70ba\u6709\u6548\uff0c\u66f4\u5b89\u5168\u3002\u66f4\u91cd\u8981\u7684\u662f\u4f7f\u7528 .htaccess \u65b9\u5f0f\u53bb\u8a2d\u5b9a\u4e0d\u9700\u8981\u7de8\u5beb\u7a0b\u5f0f\u7684\u6280\u80fd\u3002<br \/> \u9996\u5148\uff0c\u4f60\u8981\u958b\u555f\u4e00\u822c\u6587\u5b57\u7de8\u8f2f\u5de5\u5177\uff0c\u505a\u51fa\u4e00\u500b\u540d\u53eb .htpasswd \u7684\u6a94\u540d(\u7576\u7136\u53c8\u53ef\u80fd\u662f\u5176\u4ed6\uff0c\u4f46\u4e00\u822c\u4f3a\u670d\u5668\u90fd\u6703\u8a2d\u5b9a .htpasswd \u662f\u4e0d\u80fd\u7d93\u7531 http \u8b80\u5230\u7684\u3002 \u6a94\u6848\u4e2d\u7684\u7684\u6bcf\u4e00\u53e5\u4ee3\u8868\u4e00\u500b\u4f7f\u7528\u8005\uff0c\u4f7f\u7528\u8005\u540d\u7a31\u4ee5\u53ca\u52a0\u5bc6\u4e86\u7684\u5bc6\u78bc\u662f\u4ee5\u5192\u865f(:)\u5206\u9694\u3002\u800c\u5bc6\u78bc<strong>\u5fc5\u9808\u7d93\u904e\u52a0\u5bc6<\/strong>\u624d\u53ef\u4ee5\u4f7f\u7528\u3002 \u52a0\u5bc6\u7684\u65b9\u6cd5\u662f\u4e00\u822c\u5bc6\u78bc\u4f7f\u7528\u4e86\u7684 crypt\uff0c\u5982\u679c\u4f60\u4e0d\u77e5\u5982\u4f55\u52a0\u5bc6\uff0c\u8acb\u5230\u4ee5\u4e0b\u7684\u7db2\u9801\u3002<br \/> <a href=\"http:\/\/www.uhome.net\/component\/view.php?ID=16\" target=\"_blank\">UHome<\/a><br \/> <a href=\"http:\/\/www.euronet.nl\/%7Earnow\/htpasswd\/\" target=\"_blank\">http:\/\/www.euronet.nl\/~arnow\/htpasswd\/<\/a> <\/p>\n<div style=\"color: #ff0000\">\u6ce8: Win32 \u7248\u672c\u7684 apache \u597d\u50cf\u4e0d\u652f\u63f4\u7528\u4e86 crypt \u52a0\u5bc6\u6cd5\u7684\u5bc6\u78bc\u6a94\uff0c\u53ea\u652f\u63f4 SHA1 \u548c MD5 \u7684\u3002 \u5982\u679c\u4f60\u662f\u4f7f\u7528 apahce for win32 \u7248\u672c\uff0c\u8acb\u4f7f\u7528 C:Program FilesApache GroupApachebinhtpasswd.exe \u505a\u51fa\u4ee5 MD5 \u52a0\u5bc6\u7684\u5bc6\u78bc\u6a94\uff01\uff01 <\/div>\n<p>\u518d\u5728 .htaccess \u4e2d\uff0c\u52a0\u4e0a\u4ee5\u4e0b\u53e5\u5b50<\/p>\n<blockquote><p> AuthName <em>MemberPage<\/em><br \/> AuthType Basic<br \/> AuthUserFile <em>\/absolute\/path\/.htpasswd<\/em><br \/>  require valid-user <\/p><\/blockquote>\n<p> AuthName \u5c31\u662f\u7576 browser \u5f97\u77e5\u8981\u5bc6\u78bc\u6642\u6240\u51fa\u73fe\u7684\u53e5\u5b57\uff0c\u4f60\u53ef\u4ee5\u81ea\u884c\u6539\u52d5 <em>MemberPage<\/em>\uff1b \u800c\u7b2c\u4e8c\u53e5\u7684 AuthType Basic \u5c31\u5343\u842c\u4e0d\u8981\u53bb\u6539\uff1b \u7b2c\u4e09\u53e5\u7684 AuthUserFile \u5c31\u662f\u8a2d\u5b9a\u6240\u4f7f\u7528\u7684 .htpasswd \u6a94\uff0c\u8981\u7559\u610f\u5b83\u597d\u50cf\u5fc5\u9700\u662f\u5728\u4f3a\u670d\u5668\u4e0a\u7684\u7d55\u5c0d\u8def\u5f91\u3002 \u8acb\u7559\u610f\uff0c\u9019\u4e0d\u662f URL \u7684\u4f4d\u7f6e\u3001\u4e5f\u4e0d\u4e00\u5b9a\u662f\u5728 ftp \u4e2d\u770b\u5230\u7684\u4f4d\u7f6e\u3001\u5c31\u7b97\u662f\u7531 CGI \u81ea\u884c\u6e2c\u5230\u7684\u8def\u5f91\u4e5f\u672a\u5fc5\u6e96\u78ba\uff0c\u8acb\u7d30\u770b\u4f3a\u670d\u5668\u4e0a\u7684\u8aaa\u660e (\u4f8b\u5982\u5728 virtualave.net\uff0cURL \u662f \/.htpasswd ftp \u770b\u5230\u7684\u662f \/public_html\/.htpasswd\uff0cCGI \u6e2c\u5230 \/home\/public_html\/.htpasswd\uff0c\u4f46\u662f\u4e8b\u5be6\u4e0a\u4f60\u8981\u8a2d\u5b9a\u8def\u5f91\u70ba \/data1\/virtualave.net\/USERNAME\/public_html\/.htpasswd)\u3002<br \/> \u70ba\u4e86\u4fdd\u5b89\u7406\u7531\uff0c\u4e0d\u5efa\u8b70\u628a .htpasswd \u653e\u5230\u53ef\u4ee5\u7528 http \u53bb\u5230\u7684\u76ee\u9304\uff1b<br \/> \u6700\u5f8c\u7684 require \u5c31\u662f\u547d\u4ee4\u4f3a\u670d\u5668\u8ab0\u53ef\u4ee5\u9032\u5165\uff0crequire valid-user \u5c31\u662f\u6307\u53ea\u8981\u662f .htpasswd \u4e2d\u7684\u4efb\u4f55\u4e00\u4eba\u5c31\u53ef\u4e86\uff1b \u4f60\u4e5f\u53ef\u4ee5\u6307\u5b9a\u5728\u540d\u55ae\u4e0a\u53ea\u6709\u67d0\u4eba\u53ef\u4ee5\u901a\u904e\uff0crequire user <em>username<\/em> \u6216 require user <em>username1<\/em> <em>username2<\/em> <em>username3<\/em>\uff1b \u4e5f\u53ef\u4ee5\u6307\u5b9a\u662f\u67d0\u7d44\u4eba\u624d\u53ef\u4ee5\uff0crequire group <em>groupname<\/em>\u3002<\/p>\n<p> \u800c\u8a2d\u5b9a\u7d44\u7684\u65b9\u6cd5\u662f\u518d\u505a\u4e00\u500b\u53eb .htgroup \u7684\u6587\u5b57\u6a94\uff0c\u5167\u5bb9\u5982\u4e0b\uff1a <\/p>\n<blockquote><p> groupname1: username1 username2 username3<br \/> groupname2: username1 username3 username4 <\/p><\/blockquote>\n<p><\/font><\/p>\n<p> \u518d\u5728 .htaccess \u4e2d\u52a0\u591a\u4e00\u53e5 AuthGroupFile <em>\/absolute\/path\/.htgroup<\/em> \u548c .htpasswd\u3000\u7684\u65b9\u6cd5\u4e00\u6a23\uff0c\u6211\u4e0d\u518d\u8aaa\u4e86\u3002<\/p>\n<p> \u4ee5 ASCII \u6a21\u5f0f\u4e0a\u50b3\u6240\u6709\u6a94\u6848\u5f8c\uff0c\u5728\u90a3\u500b\u8cc7\u6599\u593e\u4e2d\u6240\u6709\u6a94\u6848\u90fd\u6703\u88ab\u4fdd\u8b77\u3002<br \/> \u800c\u518d\u9032\u4e00\u6b65\uff0c\u6211\u5011\u66f4\u53ef\u4ee5\u8a2d\u5b9a\u500b\u5225\u8a2d\u5b9a\u53ea\u6709\u67d0\u500b\u6a94\u6848\u6703\u5bc6\u78bc\uff0c\u4e0d\u540c\u6a94\u6848\u8981\u4e0d\u540c\u7684\u5bc6\u78bc\uff0c\u4f46\u662f\u6211\u6703\u665a\u4e00\u9ede\u624d\u8aaa\u3002<\/p>\n<p><font style=\"line-height: 200%\"> <\/font><br \/><strong><font color=\"#0000ff\">\u3010\u81ea\u8a2d\u932f\u8aa4\u5831\u544a\u6587\u4ef6 \u3011<\/font><\/strong><\/p>\n<p><font style=\"line-height: 200%\">\u60f3\u505a\u5230\u597d\u50cf www.microsoft.com \u4e00\u6a23, \u627e\u4e0d\u5230\u6587\u4ef6\u4e0d\u53ea\u662f\u5e7e\u53e5\u767d\u5e95\u9ed1\u5b57\uff0c\u4e5f\u4e0d\u662f IE \u672c\u8eab\u90a3\u500b\u6709 bug \u7684 &quot;\u627e\u4e0d\u5230\u7db2\u9801&quot;\uff0c\u800c\u662f\u53e6\u4e00\u9801 HTML \u6587\u4ef6\u55ce\uff1f<br \/> \u9022\u6cd5\u5f88\u7c21\u55ae\uff0c\u9996\u5148\u5beb\u4e00\u9801\u8aaa\u627e\u4e0d\u5230\u6587\u4ef6\u7684 HTML\uff0c\u518d\u7528 notepad \u6253\u958b\u60a8\u7684 .htaccess\u3002\u5728\u6700\u5f8c\u52a0\u4e0a\u4e00\u53e5<\/p>\n<blockquote><p> ErrorDocument <em>404<\/em> <strong>404.html<\/strong><\/p><\/blockquote>\n<p> 404.html \u662f\u932f\u8aa4\u6a94\u6848\u8def\u7d93\uff0c\u5373\u6240\u986f\u793a\u7684\u6a94\u6848\uff1b404 \u662f\u932f\u8aa4\u78bc\u3002\u4ee5\u4e0b\u5c31\u662f\u4e00\u822c\u6703\u898b\u5230\u7684\u932f\u8aa4\u78bc\u548c\u6240\u4ee3\u8868\u7684\u932f\u8aa4\u539f\u56e0\u3002 <\/p>\n<dl compact=\"compact\">\n<dt>401<\/dt>\n<dd>Authorization failed \u6388\u6b0a\u5931\u6557\uff1b\u5373\u662f\u932f\u8aa4 password<\/dd>\n<dt>403<\/dt>\n<dd>Access denied \u5b58\u53d6\u9055\u898f\uff1b\u5373\u662f\u4f60\u4e0d\u53ef\u4ee5\u8b80\u53d6\u9019\u500b\u6a94\u6848<\/dd>\n<dt>404<\/dt>\n<dd>File not found \u627e\u4e0d\u5230\u6a94\u6848<\/dd>\n<dt>500<\/dt>\n<dd>Internal Server Error \u4f3a\u670d\u5668\u5167\u90e8\u932f\u8aa4\uff1b\u53ef\u80fd\u662f http \u4f3a\u670d\u5668\u672c\u8eab\u662f\u554f\u984c\uff0c\u4e5f\u53ef\u80fd\u662f CGI \u51fa\u932f<\/dd>\n<\/dl>\n<p> \u4e5f\u6709\u4ee5\u4e0b\u5169\u985e\u505a\u6cd5<\/p>\n<blockquote><p> ErrorDocument 404 &quot;&lt;html&gt;&lt;body&gt;\u627e\u4e0d\u5230&lt;\/body&gt;&lt;\/html&gt;&quot; <br \/> ErrorDocument 500 http:\/\/www.xxx.com\/xxx<\/p><\/blockquote>\n<p><\/font><\/p>\n<p> Ps. \u5982\u679c\u6240\u7528\u7684\u932f\u8aa4\u6587\u4ef6\u662f\u4e00\u500b CGI \u6a94\uff0c\u5c31\u6703\u6709\u4e00\u9ede\u95dc\u65bc\u90a3\u500b\u932f\u8aa4\u7684\u8cc7\u79d1\u653e\u5230\u74b0\u5883\u8b8a\u6578\u5167\u7d66 CGI \u8b80\u53d6\u3002<\/p>\n<p><font style=\"line-height: 200%\"> <\/font><strong><font color=\"#0000ff\"><br \/><\/font><font color=\"#0000ff\">\u3010\u81ea\u8a2d\u9996\u9801\u6a94\u6848 \u3011<\/font><\/strong><\/p>\n<p><font style=\"line-height: 200%\">\u9019\u500b\u53ef\u4ee5\u7b97\u662f\u6700\u7c21\u55ae\u7684\u4e00\u500b\u8a2d\u5b9a\u4e86<\/p>\n<blockquote><p> DirectoryIndex <em>index.html<\/em> <em>index.htm<\/em> <em>index.cgi<\/em> <\/p><\/blockquote>\n<p><\/font><\/p>\n<p>\u5f88\u7c21\u55ae\uff0c\u5e38\u4f60\u7684\u7db2\u5740\u662f\u4e00\u500b\u76ee\u9304\uff0c\u6c92\u6709\u6ce8\u660e\u6a94\u540d\u6642 (\u5982: http:\/\/www.xxx.com\/)\u3000\u5b83\u6703\u986f\u793a index.html\u3002 \u5982\u679c\u6c92\u6709\u9019\u500b\u6a94\u6848\uff0c\u5c31\u627e\u4e0b\u4e00\u500b\u6a94\u6848\u3002\u5982\u679c\u6c92\u6709\u4efb\u53ef\u4e00\u500b\u540d\u55ae\u4e0a\u7684\u6a94\u6848\uff0c\u5c31\u6703\u4f9d\u8a2d\u5b9a\u5217\u51fa\u76ee\u9304\u5167\u7684\u6a94\u540d\u3002<\/p>\n<p><font style=\"line-height: 200%\"> <\/font><br \/><strong><font color=\"#0000ff\">\u3010\u7981\u6b62\u8b80\u53d6\u6a94\u6848 \u3011<\/font><\/strong><\/p>\n<p><font style=\"line-height: 200%\">\u5982\u679c\u4f60\u7684 CGI \u6703\u628a\u79d8\u5bc6\u7684\u5167\u5bb9(\u5982: \u5bc6\u78bc)\u5b58\u5230\u4e00\u500b\u6a94\u6848\uff0c\u90a3\u9ebc\u5225\u4eba\u53ea\u8981\u77e5\u9053\u9019\u500b\u6a94\u6848\u7684\u4f4d\u7f6e\uff0c\u5c31\u53ef\u4ee5\u5f88\u7c21\u55ae\u7684\u770b\u5230\u4e00\u5207\u3002\u4e0d\u60f3\u9019\u6a23\u55ce\uff1f\u4f60\u53ef\u4ee5\u5b8c\u5168\u4e0d\u6539\u8b8a\u5176\u4ed6\u8a2d\u5b9a\uff0c\u4e0d\u7528\u628a\u90a3\u500b\u6a94\u6848\u79fb\u5230\u5176\u4ed6\u5730\u65b9\uff0c\u53ea\u9700\u5728 .htaccess \u52a0\u5e7e\u53e5\u5c31\u53ef\u4ee5\u3002<\/p>\n<blockquote><p> &lt;Files filename.ext&gt;<br \/> \torder allow,deny<br \/> \tdeny from all<br \/> &lt;\/Files&gt;<\/p><\/blockquote>\n<p> \u800c Apache 1.3 \u4ee5\u5f8c\u7684\u7248\u672c\uff0c\u6211\u5011\u66f4\u53ef\u4ee5\u7528\u652f\u63f4 regular expression \u7684 filesmatch<\/p>\n<blockquote><p> &lt;filesmatch &quot;.tmp&quot;&gt;<br \/> \torder allow,deny<br \/> \tdeny from all<br \/> &lt;\/filesmatch&gt;<\/p><\/blockquote>\n<p> \u5176\u5be6 files \u4e5f\u53ef\u7528 regular expression \u7684\uff0c\u4f46\u8981\u52a0\u4e00\u500b ~ \u5728\u524d\uff08\u4f8b\uff1a &lt;files ~ &quot;.xxx$&quot;&gt;\uff09\u3002 files \u548c filesmatch \u7684\u610f\u601d\u5c31\u662f\uff0c\u5167\u88cf\u88ab\u5305\u8457\u7684\u5e7e\u53e5\u53ea\u6703\u5c0d\u4ed8\u5408\u8981\u6c42\u7684\u90e8\u4efd\u6a94\u6848\u751f\u6548\u3002<br \/> \u63a5\u8457\u6211\u5c31\u8aaa\u6709\u95dc\u4e2d\u9593\u7684\u6587\u5b57&rarr;order deny, allow\uff0c\u5c31\u662f\u5148\u627e\u51fa\u7981\u6b62(deny) \u7684\uff0c\u624d\u53bb\u627e\u4f8b\u5916\u8a31\u53ef\u7684 (allow)\u3002 \u5982\u679c\u628a\u5b83\u5011\u53cd\u8f49\uff0c\u5c31\u662f order allow, deny \u5c31\u662f\uff0c\u5c31\u662f\u5148\u627e\u51fa\u8a31\u53ef(allow) \u7684\uff0c\u624d\u53bb\u627e\u7981\u6b62\u7684 (deny)\u3002 \u4e4b\u5f8c\u7684 deny form <em>all<\/em> \u5c31\u662f\u8aaa\uff0c\u5168\u90e8 IP \u4f86\u7684\u90fd\u4e0d\u53ef\u4ee5\u3002 \u76f8\u5c0d\u5730 allow form <em>all<\/em> \u4e5f\u5c31\u662f\u5168\u90e8\u90fd\u53ef\u4ee5\u3002 \u800c\u4f60\u66f4\u53ef\u4ee5\u9019\u6a23\u505a<\/p>\n<blockquote><p> order allow,deny<br \/> allow form all<br \/> deny form 123.456\u3000\u3000\u3000\u3000\u3000<span style=\"color: #808080\">\u6240\u6709\u4ee5 123.456 \u958b\u59cb\u7684 IP\uff0c\u5982 123.456.1.1<\/span> <\/p><\/blockquote>\n<p> \u9664\u4e86\u8a2d\u5b9a IP \u5916\uff0c\u60a8\u4e5f\u53ef\u4ee5\u8a2d\u5b9a hostname(\u5982: xxx.com)<\/p>\n<p>  Files \u548c Filesmatch \u7684\u7528\u9014\u5f88\u591a\uff0c\u4f60\u4e0d\u4f46\u53ef\u4ee5\u8a2d\u5b9a deny\uff0c\u66f4\u53ef\u4ee5\u8a2d\u5b9a \u500b\u5225\u6a94\u6848\u7684\u5bc6\u78bc\uff0c\u5982<\/p>\n<blockquote><p> &lt;files abc&gt;<br \/> require user abc<br \/> &lt;\/files&gt;<br \/> &lt;files def&gt;<br \/> require user def<br \/> &lt;\/files&gt;<\/p><\/blockquote>\n<p> <\/font><br \/><strong><font color=\"#0000ff\">\u3010\u91cd\u65b0\u5c0e\u5411\u6587\u4ef6 \u3011<\/font><\/strong><\/p>\n<p><font style=\"line-height: 200%\">\u5c31\u662f\u91cd\u65b0\u5c0e\u5411\u6587\u4ef6\u3002<\/p>\n<blockquote><p> Redirect \/abc http:\/\/www.xxx.com\/abcabc<br \/> Redirect permanent \/def http:\/\/www.xxx.com\/def<\/p><\/blockquote>\n<p><\/font><\/p>\n<p> \u5373\u662f\u8aaa\uff0c\u5982\u679c browser \u8981\u6c42 http:\/\/_____\/abc \u5b83\u5c31\u6703\u91cd\u65b0\u5c0e\u5411\u81f3 http:\/\/www.xxx.com\/abcabc\u3002 \u800c\u7b2c\u4e8c\u53e5\u53c8\u6709\u751a\u9ebc\u4e0d\u540c\u5462\uff1f\u7b54\u6848\u5c31\u662f http \u7684\u72c0\u80fd\u78bc\u4e0d\u540c\uff0cparmanet (301) \u662f\u6c38\u9060\u7684\uff0c\u4ee3\u8868 browser \u4e0b\u4e00\u6b21\u672a\u5fc5\u6703\u518d\u8981\u6c42\u9019\u6a94\u6848\uff0c\u800c\u76f4\u63a5\u627e\u53e6\u4e00\u500b\u3002\u9664\u4e86 permanent \u4e4b\u5916\uff0c\u9084\u6709 temp ( 301\uff1b\u548c\u4e0d\u5beb\u4e00\u6a23)\u3001seeother(303) \u548c gone(410)\u3002<br \/> \u4e5f\u6709 RedirectMatch\uff0c\u4e0d\u904e\u5b83\u5c31\u652f\u63f4 regular expression\u3002<\/p>\n<p><font style=\"line-height: 200%\"> <\/font><br \/><strong><font color=\"#0000ff\">\u3010\u9632\u6b62\u5217\u51fa\u76ee\u7da0\u5167\u7684\u6a94\u6848 \u3011<\/font><\/strong><\/p>\n<p><font style=\"line-height: 200%\">\u5176\u5be6\u8981\u505a\u5230\u9019\u500b\u76ee\u6a19\u53ef\u4ee5\u4e0d\u7528 .htaccess\uff0c\u4f60\u53ea\u8981\u81ea\u5df1\u5beb\u4e00\u9801 index.html \u653e\u5165\u53bb\u5c31\u53ef\u4ee5\u4e86\u3002\u4f46\u662f\uff0c\u7528 .htaccess \u6703\u65b9\u4fbf\u5f88\u591a\uff0c\u5728 .htaccess \u4e2d\u52a0\u4e00\u53e5\u3002<\/p>\n<blockquote><p> Options -Indexes <\/p><\/blockquote>\n<p> \u9019\u6a23\u505a\uff0c\u4f3a\u670d\u5668\u5c31\u4e0d\u6703\u591a\u4e8b\u5730\u628a\u76ee\u9304\u5167\u7684\u6a94\u540d\u5217\u51fa\u3002\u5982\u679c\u4f60\u53ea\u4e0d\u904e\u662f\u60f3\u4e0d\u5217\u51fa\u67d0\u5e7e\u500b\u6a94\u6848\uff0c\u8acb\u7528\u4ee5\u4e0b\u7684\u8a2d\u5b9a<\/p>\n<blockquote><p> IndexIgnore <em>*.gif<\/em> <em>*.jpg<\/em> <\/p><\/blockquote>\n<p>\u6211\u60f3\u5c31\u7b97\u53ea\u8b58\u4e00\u9ede\u82f1\u6587\u7684\u4eba\u4e5f\u6703\u660e\u767d\uff0c\u5c31\u662f\u5728\u5217\u51fa\u6a94\u540d\u6642\u4e0d\u7406\u6703(ignore) \u5f8c\u9762\u7684\u6a94\u6848\u3002<\/p>\n<p>  Ps. \u5982\u679c\u8a2d\u5b9a\u4e86 IndexIgnore *\uff0c\u5b83\u5c31\u4e0d\u6703\u5217\u51fa\u4efb\u4f55\u6a94\u6848\uff0c\u4f46\u662f\u6703\u6709 HEADER \u548c README \u7684\u5167\u5bb9\uff0c\u800c\u5b83\u5011\u662f\u53ef\u4ee5\u81ea\u8a2d\u7684\u3002 <\/font> \t\t<\/p>\n<p>&nbsp; <\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4ee5\u4e0b\u5167\u5bb9\u662f\u8f49\u8cbc\u65bc\u6211\u7684\u820a\u90e8\u843d\u683c\u4e2d\u7684\u4e00\u7bc7\u6587\u7ae0 \u8cc7\u6599\u4f86\u6e90\u7db2\u7ad9\u5efa\u7f6e\u767e\u5bf6\u7bb1 \u525b\u597d\u6700\u8fd1\u9047\u5230\u4e00\u9ede\u985e\u4f3c\u7684\u554f\u984c\uff0c\u56e0\u6b64\u5c31\u8cbc\u51fa\u4f86\u548c\u5927<span class=\"post-excerpt-end\">&hellip;<\/span><\/p>\n<p class=\"more-link\"><a href=\"https:\/\/learn-house.idv.tw\/?p=100\" class=\"themebutton\">Read More<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-100","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/learn-house.idv.tw\/index.php?rest_route=\/wp\/v2\/posts\/100","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/learn-house.idv.tw\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/learn-house.idv.tw\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/learn-house.idv.tw\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/learn-house.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=100"}],"version-history":[{"count":0,"href":"https:\/\/learn-house.idv.tw\/index.php?rest_route=\/wp\/v2\/posts\/100\/revisions"}],"wp:attachment":[{"href":"https:\/\/learn-house.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=100"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/learn-house.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=100"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/learn-house.idv.tw\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=100"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}