Apache Indexed Directory Browsing Learning notes

Source: Internet
Author: User

When you browse some image file stations, you will find that the site directory is a list of files (folders) that can be browsed. Give two examples: NetEase open source image; Ubuntu. As long as the Web server is an Apache-based Web site can be opened or disabled index (directory browsing), then how to implement prohibit and open Display directory index it?

I. Prohibit Apache from displaying directory indexes
Method 1, modify the Apache configuration file [httpd.conf]
(1) Directory Configuration

<directory/home/www.111cn.net/teddysun "> #Options Indexes followsymlinks Options followsymlinks allowoverride None Order allow,deny allow from all </Directory>

Change Options Indexes followsymlinks to Options FollowSymLinks

That is, Apache can be prevented from displaying the directory structure.
Explanation: The role of Indexes is that when a index.html file is not specified in the directory, the directory structure is displayed, and the Indexes is removed, and Apache does not display a list of that directory.

(2) Virtual machine configuration

<virtualhost *:80> ServerName  domain serveralias  domainsdocumentroot/home/www/  /home/www/teddysun/logs/access. Log Combined DirectoryIndex index. PHP index.  <Directory/home/www/teddysun>+includes-Indexes allowoverride all Order Deny,  </Directory> </virtualhost>

Here, in front of the indexes, the-symbol also prevents Apache from displaying the directory structure.
Explanation: Before indexes, the Plus + delegate allows directory browsing; plus – disables directory browsing.

Method 2, modify the. htaccess file
Modify the. htaccess file at the site root to add the following code (if none. htaccess file is new):

<files *>-</Files>

Explanation: Before indexes, the Plus + delegate allows directory browsing; plus – disables directory browsing.

Second, open and customize Apache Display directory index style

(1) Modifying the Apache configuration file [httpd.conf]

<directory/home/www/teddysun ""/css/style.css " indexoptions fancyindexing HTMLTable scanhtmltitles Foldersfirst namewidth=85 descriptionwidth=128 iconwidth=16 iconheight=16 versionsort Charset=UTF-8 AllowOverride All Order Allow,deny allow from all </Directory>

Explanation: When you write Indexes in the options option, the Directory browsing feature is turned on. CentOS6 installed by Yum in the default is directory browsing, but using the browser to access the first page, but can not display the table of contents, because the/etc/httpd/conf.d/welcome.conf file in front of the Indexes there is a-symbol, Apache disables the Directory browsing feature on the home page by default.

(2) Custom index (directory browsing) style
The Indexoptions option in the previous step allows you to customize the index (directory browsing) style as follows:
Fancyindexing Opening Directory browsing adornments
HTMLTable This option builds a simple table with fancyindexing for directory browsing adornments.
Scanhtmltitles Searching for HTML titles
Foldersfirst Directory priority in front
Namewidth=85 indicates that a file name can display up to 85 English characters
Descriptionwidth=128 that describes the number of characters that can be displayed
iconwidth=16 icon width (in pixels)
iconheight=16 icon height (in pixels)
Versionsort version sort, if not, will be sorted in alphabetical order
Charset=utf-8 Character Set

Other such as:
Addaltclass, Iconsarelinks, IgnoreCase, Ignoreclient, Showforbidden, suppresscolumnsorting, Suppressdescription, Suppresshtmlpreamble, Suppressicon, suppresslastmodified, Suppressrules, Suppresssize, TrackModified, type, etc. please read the reference link.

< reference:http://www.3lian.com/edu/2014/01-11/123660.html>

Apache Indexed Directory Browsing Learning notes

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.