Maps as aliases that fall through

All but one of the web servers that I am familiar with use the same basic model for locating objects on the server. Usually, there is a root directory where the URL is checked for as if it were a path in the file system. Some servers allow aliases that use a prefix of the URL to indicate a directory other than the root. CGI directories are treated similarly. If the URL does not appear in the directory determined by the alias mechanism, then a not found result is returned to the client.

In contrast to this, a map that fails to find the file referred to by the URL will not return a not found result, but will tell the server that it didn't do anything. The server then continues checking the other maps available, and returns a not found result when it runs out of such maps.

If you had nothing but directory maps, there would be little difference between maps and aliases, except that maps allow a three dimensional structure for documents on the server with directory trees layered one on top of another as you apply different maps which use the same prefix.

However, because maps don't fail to find objects, modules can take on tasks that normally require direct server support.

For example, host authentication is a popular means of restricting access to an area of the server. The authhost module does that. For example:

map /private/ authhost - #?.foo.net
map /private/ directory private:

causes access from anywhere except the foo.net domain to fail with a object not found error. The "-" in the middle can be replaced by a filename to allow sending a specific message instead of a generic object not found message. If the host is in the foo.net domain, the authhost module "does nothing", allowing the next directory map to handle the access to /private/.

Similarly, the authbasic module checks HTTP Basic authentication information, and either quietly falls through or returns a not authorized response. If authorization succeeds, then authhost annotates the request with the user name and authorization method for use by further maps, or for server logging.


Next, Previous, Contents

Mike Meyer