Using .htaccess files to control directory listings
At Precedence Internet, we use a webserver called Apache. This is most widely used webserver in the world.
Apache is highly configurable and it is possible for some options to be
set by the end user. This is performed by creating text file called .htaccess
in your directories.
A brief guide is given below, but this
is no substitute for having read the
Apache documentation.
Configuring directory listings
If you create a directory without a suitable home page in it (index.html, index.htm, index.php, index.php3, index.txt), then a directory listing will be returned. It is often useful to define descriptions and headers/footers for such listings. For example, look at this page. Boring, isn't it? Now look at this page.
The second example is a copy of the first, but it has had a header and a footer added. Also, each item has been given a short description and one item has been hidden.
To do this, firstly create your header and/or footer files as plain text files. In this example, they are called header.txt and footer.txt. Use the following lines in your .htaccess file:
| Command | Description |
| HeaderName <filename> | Use <filename> as a header |
| ReadMeName <filename> | Use <filename> as a footer |
| IndexIgnore <filename> | Ignore <filename> when listing the directory |
| AddDescription "description" <filename> | Use description as a description for <filename> |
For example, the .htaccess in the second example was:
HeaderName header.txt
ReadMeName footer.txt
IndexIgnore header.txt
IndexIgnore footer.txt
IndexIgnore old-stale-fish
AddDescription "Nice in batter" cod
AddDescription "Sweeter than cod" haddock
AddDescription "Sort of flat" plaice
Precedence Technologies Ltd, 120 Cambridge Science Park, Milton Road, Cambridge, UK | Tel: 08456 446 800 Revision:1.1 Wed May 17 09:45:54 2006 |