說明禁止Apache顯示目錄索引的常見的3種方法。要Apache禁止顯示目錄索引,只需將Options中的Indexes去掉即可。
(1)修改目錄配置:
Options Indexes FollowSymLinks <== 修改為: Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
Indexes 的作用就是當該目錄下沒有 index.html 檔案時,就顯示目錄結構,去掉 Indexes ,Apache 就不會顯示該目錄的列表了。
(2)修改Apache配置檔案[httpd.conf]
搜尋“Options Indexes FollowSymLinks”,修改為“Options FollowSymLinks”即可。
Options Indexes FollowSymLinks刪除Indexes,這樣的話就屬於整個Apache禁止目錄瀏覽了。
如果是配置虛擬機器,
Options FollowSymLinks <== 刪除Indexes 即可
ServerAdmin mail@example.cxm
DocumentRoot "../vhosts/example.cxm"
ServerName shopex:80
ServerAlias example.cxm
ErrorLog logs/example.cxm-error_log
(3)通過.htaccess檔案
可以在根目錄新建或修改 .htaccess 檔案中新增
Options FollowSymLinks