• Aucun résultat trouvé

mod_autoindex

Dans le document Apache Server2 Apache Server2 (Page 162-167)

The mod_autoindexmodule is compiledin Apache by default. When Apache receives a request for a directory, it looks for one or more of the directory index files specified by the DirectoryIndexdirective. Typically, this file is index.html or index.htm. In the absence of such an index file, however, Apache can generate a dynamic directory listing. This module enables you to control how Apache creates the dynamic directory listing.

Apache generates two types of dynamic directory indices: simple and fancy. The fancy index and many other indexing options are available from this module. The directives for mod_authoindexare as follow.

AddAlt

When FancyIndexingis on, this directive sets the specified text as an alternative to the icon that is displayed for one or more files or file extensions specified as arguments. This is done for nongraphical browsers such as Lynx.

Syntax:AddAlt “text” filename [filename ...]

Context:Server config, virtual host, directory, per-directory access control file (.htaccess)

Override:Indexes

For example, the following directive enables Apache to display the alternative text

“Pictures”in place of the icon for each type of graphic file specified here. For graphical browsers such as Netscape Navigator or Internet Explorer, the alternative text is displayed as help text under popular Windows platforms. In such systems, users can get a tip or help about the file when they move their mouse cursor on top of the icon representing one of the file types.:

AddAlt “Pictures” gif jpeg jpg bmp

AddAltByEncoding

If you do not like to assign alternative text to filenames or file extensions via the AddAltdirective, you can use the AddAltByEncodingdirective to assign such text for one or more MIME encodings. Like AddAlt, this directive is also only usable when FancyIndexingis turned on.

Syntax:AddAltByEncoding “text” MIME_encoding [MIME_encoding ...]

Context:Server config, virtual host, directory, per-directory access control file (.htaccess)

Override:Indexes

For example, the following directive makes Apache display the “Compressed File”

alternative text for all files of MIME type x-compress. AddAltByEncoding “Compressed File” x-compress

AddAltByType

Like the AddAltByEncodingdirective, the AddAltByTypedirective sets alternative text for a file, instead of an icon for FancyIndexing. However, it uses a MIME type instead of MIME encoding.

Syntax:AddAltByType “text” MIME-type [MIME_type ...]

Context:Server config, virtual host, directory, per-directory access control file (.htaccess)

Override:Indexes

For example, the following directive shows the “HTML FILE”text in place of the icon for nongraphical browsers. In the case of graphical browsers, this text may appear as a tip or help:

AddAltByType “HTML FILE” text/html

AddDescription

The AddDescriptiondirective sets the description text for a filename, for a partial filename, or for a wild-card filename when FancyIndexingis turned on.

Syntax:AddDescription “text” file [ file ... ]

Context: Server config, virtual host, directory, per-directory access control file (.htaccess)

Override:Indexes

For example, the following directive displays the description for all GIF, JPEG, JPG, and BMP files in generated directory listing:

AddDescription “Graphics File” *.gif *.jpeg *.jpg *.bmp

AddIcon

The AddIcondirective enables you to assign icons to files and directory names that are displayed for FancyIndexing.

Syntax:AddIcon icon name file [filename ...]

Context:Server config, virtual host, directory, per-directory access control file (.htaccess)

Override:Indexes

For example, the following directive tells Apache to show /icons/picture.gif next to files that have extensions such as .gif, .jpg, and .bmp:

AddIcon /icons/picture.gif .gif .jpg .bmp

If you also want to provide alternative text for the file extension listed, you can use a format such as the following, where IMGis the alternative text displayed for non-graphical browsers:

AddIcon (IMG, /icons/picture.gif) .gif .jpg .bmp

If you want to display an icon for a directory, you can use the directive as follows:

AddIcon /path/to/your/directory/icon ^^DIRECTORY^^

Similarly, if you want to display an icon for each blank line displayed by the fancy indexing scheme, you can use:

AddIcon /path/to/your/blank/line/icon ^^BLANKICON^^

AddIconByEncoding

The AddIconByEncodingdirective lets you assign icons to MIME-encodings. In other words, you can assign an icon image to a MIME type.

Syntax:AddIconByEncoding icon_file MIME_encoding [MIME_encoding...]

Context:Server config, virtual host, directory, per-directory access control file (.htaccess)

Override:Indexes

For example, the following AddIconByEncodingdirective tells Apache to display /icons/zip.gificon for all files that are x-gzip(i.e. .gzextension) MIME type files.

AddIconByEncoding /icons/zip.gif x-gzip

AddIconByType

The AddIconByTypedirective also enables you to assign icons to one or more MIME types.

Syntax:AddIconByType icon_file MIME_type [MIME_type...]

Context:Server config, virtual host, directory, per-directory access control file (.htaccess)

Override:Indexes

For example, the following AddIconByTypedirective tells Apache to display the /icons/html.gificon for all text/htmlfiles.

AddIconByType (HTML,/icons/html.gif) text/html

DefaultIcon

When no AddIcon, AddIconByEncoding, or AddIconByTypeis matched for a file, a default icon can be displayed. The DefaultIcondirective enables you to set that icon.

Syntax: DefaultIcon URL

Context:Server config, virtual host, directory, per-directory access control file (.htaccess)

Override:Indexes

For example, the following directive shows idontknow.gifwhenever a file’s icon association is unknown:

DefaultIcon /icon/idontknow.gif

FancyIndexing

The FancyIndexingdirective lets you enable and disable fancy indexing of directo-ries. You can achieve the same effect with the IndexOptionsdirective.

Syntax:FancyIndexing On | Off

Context:Server config, virtual host, directory, per-directory configuration (.htaccess)

Override:Indexes

HeaderName

If you use FancyIndexing, you can insert a file’s content at the top of the index list-ing. The HeaderNamedirective lets you specify the name of the file for such an insertion.

Syntax:HeaderName filename

Context:Server config, virtual host, directory, per-directory access control file (.htaccess)

Override:Indexes

For example, the following directive tells Apache to look for a file called welcomeor welcome.htmlin the directory of the listing; if such a file is found, the content is inserted before the actual listing:

HeaderName welcome

IndexIgnore

If you need some files or file extensions to be invisible in the directory listing, you can use the IndexIgnoredirective to accomplish this.

Syntax:IndexIgnore file [file...]

Context:Server config, virtual host, directory, per-directory access control file (.htaccess)

Override:Indexes

For example, the following directive ensures that Apache does not list welcome, welcome.html, or per-directory configuration (.htaccess) files in directory listings:

IndexIgnore welcome welcome.html.htaccess

The .(dot) character is automatically in the IndexIgnorelist; thus, files that start with this character are not listed. However, you may still prefer to add per-directory configuration (.htaccess) in the list, just so that you feel safer.

IndexOptions

The IndexOptionsdirective specifies the behavior of the automatically generated directory indexing.

Syntax:IndexOptions option [option] [...]

Context: Server config, virtual host, directory, per-directory access control file (.htaccess)

Override: Indexes

Table 5-7 shows the options that you can use with IndexOptions.

Table 5-7

Dans le document Apache Server2 Apache Server2 (Page 162-167)