Common methods for prohibiting Apache from displaying directory indexes

  

Disable Apache from displaying directory indexes, prohibiting Apache from displaying a list of directory structures, and prohibiting Apache from browsing directories. This is a lot of online questions, but it is actually a meaning. The following are three common ways to prohibit Apache from displaying directory indexes.

To disable Apache from displaying directory indexes, simply remove the Indexes from Option.

1) Modify the directory configuration:

<Directory "D:/Apache/blog.phpha.com"> Options Indexes FollowSymLinks # Modify to: Options FollowSymLinks AllowOverride None Order allow, Deny Allow from all </Directory>

Just remove the Indexes from the above code to prevent Apache from displaying the directory structure. Users will not see the list of files and subdirectories under this directory. The role of Indexes is to display the directory structure when there is no index.html file in the directory. If Indexes is removed, Apache will not display the list of directories.

2) Modify the Apache configuration file [httpd.conf]

Search “Options Indexes FollowSymLinks”, change to “Options -Indexes FollowSymLinks” In the Options Indexes FollowSymLinks, precede the Indexes with the – symbol. Note: Before Indexes, add + to allow directory browsing; add – to prohibit directory browsing. In this case, it belongs to the entire Apache banned directory browsing. If you are configuring a virtual machine, the following is true:

<VirtualHost *> <Directory "../vhosts/blog.phpha.com"> Options -Indexes FollowSymLinks # Modify to -Indexes </Directory> ServerAdmin [email protected] DocumentRoot "../vhosts/blog.phpha.com" ServerName shopex:80 ServerAlias ​​blog.phpha.com ErrorLog logs/blog.phpha.com-error_log </VirtualHost>

3) via the .htaccess file

You can add

<Files *> Options -Indexes </Files> to the root directory to create or modify the .htaccess file.

You can disable Apache from displaying directory indexes.

Copyright © Windows knowledge All Rights Reserved