Learning notes for the Apache index directory browsing

Source: Internet
Author: User
Tags character set

When you browse some of the mirrored file stations, you will find that the site directory can browse the list of files (folders). Give two examples: NetEase open source Mirror, Ubuntu. As long as the Web server is based on the Apache Web site can be turned on or off the index (directory browsing), then how to implement the Disable and open the Display directory index?


First, prohibit Apache display directory index
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, you can prevent Apache from displaying the directory structure.
Explanation: Indexes's role is when the directory does not specify index.html file, the directory structure, remove Indexes, Apache will not display the list of the directory.

(2) Virtual machine configuration

<virtualhost *:80>
ServerName Domain
Serveralias domains
Documentroot/home/www/teddysun
Customlog/home/www/teddysun/logs/access.log combined
DirectoryIndex index.php index.html
<Directory/home/www/teddysun>
Options +includes-indexes
AllowOverride All
Order Deny,allow
Allow from all
</Directory>
</virtualhost>

Here, before indexes Plus – the symbol also prevents Apache from displaying the directory structure.
Explanation: Before indexes, plus + represents allow directory browsing, plus – represents a ban on directory browsing.

Method 2, modify the. htaccess file
Modify the. htaccess file at the site root, adding the following code (new if no. htaccess file):

<files *>
Options-indexes
</Files>

Explanation: Before indexes, plus + represents allow directory browsing, plus – represents a ban on directory browsing.

Second, open and customize Apache Display directory index style

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

<directory/home/www/teddysun ">
Options Indexes FollowSymLinks
Indexstylesheet "/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: Write Indexes in the options option, that is, the Directory browsing feature is turned on. CentOS6 in the Yum installed by default is open Directory browsing, but the use of the browser to access the home page, but can not display the directory, because the/etc/httpd/conf.d/welcome.conf file in front of the Indexes-symbol, that is, 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 Open Directory Browsing decoration
HtmlTable This selection builds a simple table with fancyindexing to decorate the catalog browsing.
Scanhtmltitles Search HTML title
Foldersfirst Directory priority in front
NAMEWIDTH=85 indicates that a filename can display up to 85 English characters
DESCRIPTIONWIDTH=128 represents 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 phonetic 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.

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.