禁止apache顯示目錄索引 apache禁止列目錄

禁止apache顯示目錄索引 apache禁止列目錄

禁止Apache顯示目錄索引的常見的3種方法。php

要實現禁止Apache顯示目錄索引,只需將Option中的Indexes去掉便可。html

禁止Apache顯示目錄索引,禁止Apache顯示目錄結構列表,禁止Apache瀏覽目錄,這是網上提問比較多的,其實都是一個意思。apache

下面說下禁止Apache顯示目錄索引的常見的3種方法。
要實現禁止Apache顯示目錄索引,只需將 Option 中的 Indexes 去掉便可。
1)修改目錄配置:
<Directory "D:/Apache/blog.phpha.com">
Options Indexes FollowSymLinks # 修改成: Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
只須要將上面代碼中的 Indexes 去掉,就能夠禁止 Apache 顯示該目錄結構。用戶就不會看到該目錄下的文件和子目錄列表了。Indexes 的做用就是當該目錄下沒有 index.html 文件時,就顯示目錄結構,去掉 Indexes ,Apache 就不會顯示該目錄的列表了。
2)修改Apache配置文件[httpd.conf]
搜索「Options Indexes FollowSymLinks」,修改成「Options -Indexes FollowSymLinks」便可。
在Options Indexes FollowSymLinks在Indexes前面加上 – 符號。備註:在Indexes前,加 + 表明容許目錄瀏覽;加 – 表明禁止目錄瀏覽。這樣的話就屬於整個Apache禁止目錄瀏覽了。
若是是配置虛擬機,則以下:
<VirtualHost *>
<Directory "../vhosts/blog.phpha.com">
Options -Indexes FollowSymLinks # 修改成 -Indexes 便可
</Directory>
ServerAdmin mail@jbxue.com
DocumentRoot "../vhosts/www.jbxue.com"
ServerName shopex:80
ServerAlias blog.phpha.com
ErrorLog logs/blog.phpha.com-error_log
</VirtualHost>
3)經過.htaccess文件
在根目錄新建或修改 .htaccess 文件中添加
<Files *>
Options -Indexes
</Files>
禁止Apache顯示目錄索引。ide

相關文章
相關標籤/搜索