默認apache在當前目錄下沒有index.html入口就會顯示目錄。讓目錄暴露在外面是非常危險的事,如下操作禁止apache顯示目錄,希望文章對各位有幫助。
進入apache的配置文件 httpd.conf 找到:
| 代碼如下 | 復制代碼 |
| Options Indexes FollowSymLinks 修改為: Options FollowSymLinks |
|
其實就是將Indexes去掉,Indexes表示若當前目錄沒有index.html就會顯示目錄結構。
| 代碼如下 | 復制代碼 |
| 1. 禁止訪問某些文件/目錄 禁止訪問某些指定的目錄:(可以用 <DirectoryMatch> 來進行正則匹配) 通過文件匹配來進行禁止,比如禁止所有針對圖片的訪問: 針對URL相對路徑的禁止訪問: |
|
配置示例:
| 代碼如下 | 復制代碼 |
| <Directory "E:/Program Files/Apache Software Foundation/Apache2.2/htdocs"> # # Possible values for the Options directive are "None", "All", # or any combination of: # Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews # # Note that "MultiViews" must be named *explicitly* --- "Options All" # doesn't give it to you. # # The Options directive is both complicated and important. Please see # http://httpd.apache.org/docs/2.2/mod/core.html#options # for more information. # 就是這一行,只去掉indexes也可 #Options Indexes FollowSymLinks Options FollowSymLinks # # AllowOverride controls what directives may be placed in .htaccess files. # It can be "All", "None", or any combination of the keywords: # Options FileInfo AuthConfig Limit # AllowOverride None # # Controls who can get stuff from this server. # Order allow,deny Allow from all </Directory> 建議默認情況下,設置APACHE禁止用戶瀏覽目錄內容。 |
|
