Module mod_dir

Important: Information for this topic supports the latest PTF levels for HTTP Server for i5/OS . It is recommended that you install the latest PTFs to upgrade to the latest level of the HTTP Server for i5/OS. Some of the topics documented here are not available prior to this update. See http://www.ibm.com/servers/eserver/iseries/software/http/services/service.htm Link outside Information Center for more information.

Summary

The module mod_dir provides "trailing slash" redirects and serving directory index files. The index of a directory can come from one of two sources:

The two functions are separated so you can completely remove (or replace) automatic index generation.

By default, a trailing slash ('/') redirect is issued when the server receives a request for a URL http://servername/QIBM/dirname where dirname is a directory. Directories require a trailing slash, so mod_dir issues a redirect to http://servername/QIBM/dirname/.

The AlwaysDirectoryIndex directive controls how the server will respond to directory requests.

Directives

AlwaysDirectoryIndex

Module: mod_dir
Syntax: AlwaysDirectoryIndex on | off
Default: Always DirectoryIndex on
Context: server config, virtual host, directory, .htaccess
Override: Indexes
Origin: iSeries™
Example: AlwaysDirectoryIndex off

The AlwaysDirectoryIndex directive specifies if you want the server to always handle directory requests by first searching the directory for an index (Welcome) file.

Parameter: on | off
  • The on parameter sets the server to always search the directory for an index file, regardless of whether a trailing slash ('/') exists in the URL. The DirectoryIndex directive specifies the names of the files that the server recognizes as index (Welcome) files.
  • The off parameter sets the server to first check the last character of requests that refer to iSeries files, QDLS folders, or integrated file system directories for the slash ('/') character. If the directory request ends with a slash, the server searches the directory for an index file. If the directory request does not end with a slash, the server attempts to return a directory listing (rather then doing a "trailing slash" redirect).

If the server does not find an index file, or AlwaysWelcome is set to off and the directory request does not end in a slash, Options controls whether or not the server responds to the request with a directory listing.

DirectoryIndex

Module: mod_dir
Syntax: DirectoryIndex local-url [local-URL ...]
Default: DirectoryIndex index.html
Context: server config, virtual host, directory, .htaccess
Override: Indexes
Origin: Apache
Example: DirectoryIndex bob.html index.html

The DirectoryIndex directive sets the list of resources to look for, when the client requests an index of the directory by specifying a / at the end of the a directory name. Local-URL is the (%-encoded) URL of a document on the server relative to the requested directory; it is usually the name of a file in the directory. Several URLs may be given, in which case the server will return the first one that it finds. If none of the resources exist and the Indexes option is set, the server will generate its own listing of the directory.

Parameter: local-url
  • The local-url parameter is the (%-encoded) URL of a document on the server relative to the requested directory; it is usually the name of a file in the directory. For example:
    DirectoryIndex index.html

A request for http://myserver/docs/ would return http://myserver/docs/index.html if it exists, or it would list the directory if it did not exist.

The documents do not need to be relative to the directory. For example:

DirectoryIndex index.html index.txt /cgi-bin/index.pl

This would cause the CGI script /cgi-bin/index.pl to be run if neither index.html or index.txt existed in a directory. This same idea will also work for QSYS.LIB files. For example, if the directory index is stored in /QSYS.LIB/MYLIB.LIB/MYFILE.FILE/INDEX.MBR, you would need to specify DirectoryIndex Index.mbr.

This directive may be configured multiple times in a container. The directives are processed from the first to the last occurrence.