You've probably noticed that most web pages are not retrieved by a specific filename. Instead of typing a URL like this:
you instead usually enter:
This URL maps to a directory named dirname, beneath the directory defined in the server configuration as the DocumentRoot. It is the responsibilty of the module mod_dir to serve a specific page to clients that send a request URL that maps to a directory. Without mod_dir, the second form would be invalid and produce an HTTP 404 error.
Therefore, mod_dir performs two important functions. First, whenever a request is received that maps to a directory but does not have the '/', such as:
mod_dir sends a redirection request to the client indicating that the request should be made to the URL:
This requires a second request from the client, but is generally unnoticed by the user. Omitting the trailing slash is technically an error in the request and you should always include it for the sake of correctness and efficieny.
The second function is to serve a file defined as the index file for the directory specified in the request.
index.html is the default for Apache and is set with the
DirectoryIndex directive.
If you're getting an error when you omit the '/', the chances are you don't have an index file in the directory you're requesting. ------------------------------------------------------------------
It's important to think. It's what separates us from lentils.