Recipe 12.7 Alternate Default Document

Problem

You want to have some file other than index.html appear by default.

Solution

Use DirectoryIndex to specify the new name:

DirectoryIndex default.htm

Discussion

When a directory is requested that is, a URL ending in a / rather than in a file name mod_dir will select the index document from that directory and serve that file in response. By default, the index file is assumed to be index.html, but this can be configured to something else with the DirectoryIndex directive.

Note also that DirectoryIndex can be set to several files, which are listed in order of precedence:

DirectoryIndex index.html index.htm index.php default.htm

Finally, note that you can also provide a relative URL if you want to load content from some other directory, such as a CGI program:

DirectoryIndex /cgi-bin/index.pl

See Also

  • http://httpd.apache.org/docs/mod/mod_dir.html



Apache Cookbook
Apache Cookbook: Solutions and Examples for Apache Administrators
ISBN: 0596529945
EAN: 2147483647
Year: 2006
Pages: 215

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net