[root@kvm3 ~]# cd /var/www/html/ [root@kvm3 html]# mkdir dirtest [root@kvm3 html]# echo 'aaa' > dirtest/aaa [root@kvm3 html]# echo 'bbb' > dirtest/bbb [root@kvm3 html]# echo 'ccc' > dirtest/ccc
[root@kvm3 html]# vim /etc/httpd/conf/httpd.conf [root@kvm3 html]# grep dirtest -A4 /etc/httpd/conf/httpd.conf <Directory "/var/www/html/dirtest"> AllowOverride None Options Indexes Require all granted </Directory>
[root@kvm3 html]# systemctl restart httpd.service
Options -Indexes
,取消列出目錄檔案。
[root@kvm3 html]# vim /etc/httpd/conf/httpd.conf [root@kvm3 html]# grep dirtest -A4 /etc/httpd/conf/httpd.conf <Directory "/var/www/html/dirtest"> AllowOverride None Options -Indexes Require all granted </Directory>
[root@kvm3 html]# systemctl restart httpd.service
[root@kvm3 html]# curl http://kvm3.deyu.wang/dirtest/ <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html><head> <title>403 Forbidden</title> </head><body> <h1>Forbidden</h1> <p>You don't have permission to access /dirtest/ on this server.</p> <hr> <address>Apache Server at kvm3.deyu.wang Port 80</address> </body></html>
[root@kvm3 ~]# cd /var/www/html/abc [root@kvm3 abc]# touch index.html
Options -Indexes
,取消列出目錄檔案。在 httpd.conf 中將開放瀏覽的目錄獨立設定 Indexes,則連到 http://kvm3.deyu.wang/abc 時就會到出目錄中的檔案。
[root@kvm3 ~]# vim /etc/httpd/conf/httpd.conf <Directory "/var/www/html/abc"> Options Indexes AllowOverride None Require all granted </Directory>