2010年3月23日

如何避免 Apache 網站的目錄內容顯示出來

環境:CentOS with Apache/2.2.3

cd /etc/httpd/conf
vim httpd.conf

找尋下面這段文字,並把 Indexes 刪除
<Directory "/var/www/html">
Options Indexes FollowSymLinks
AllowOverride None Order allow,deny
Allow from all
</Directory>

如下
<Directory "/var/www/html">
Options FollowSymLinks
AllowOverride None Order allow,deny
Allow from all
</Directory>

存檔

重起服務
service httpd restart

測試應該就會出現
Forbidden
You don't have permission to access /hello/image on this server.

收工~