Common ways to prevent Apache from displaying directory indexes

Source: Internet
Author: User

Prohibit Apache display directory index, prohibit Apache display directory structure list, prohibit Apache Browse directory, this is the online question more, in fact, is a meaning. The following is a list of common 3 ways to prohibit Apache from displaying directory indexes.
To implement a ban on Apache from displaying directory indexes, simply remove the Indexes in Option.

1) Modify the directory configuration:

The code is as follows:
<directory "D:/apache/blog.phpha.com" >
Options Indexes FollowSymLinks # Modified 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. The user will not see a list of files and subdirectories under that directory. The role of Indexes is that when there is no index.html file in the directory, the directory structure is displayed, and the Indexes is removed, and Apache does not display a list of that directory.

2) Modify Apache configuration file [httpd.conf]

Search for "Options Indexes followsymlinks" and Change to "Options-indexes followsymlinks".
In the options Indexes followsymlinks in front of the Indexes plus – symbol. Note: Before indexes, the Plus + delegate allows directory browsing; plus – disables directory browsing. This is the entire Apache Ban directory browsing.
If you are configuring a virtual machine, the following:

The code is as follows:
<virtualhost *>
<directory ". /vhosts/blog.phpha.com ">
Options-indexes FollowSymLinks # Change 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) through the. htaccess file

You can add new or modified. htaccess files in the root directory

The code is as follows:
<files *>
Options-indexes
</Files>

You can disable Apache from displaying directory indexes.

Common ways to prevent Apache from displaying directory indexes

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.