Sambar Server Documentation

Directory Aliasing


Aliasing Overview
The [aliases], [cgi-aliases] and [wincgi-aliases] sections of the mappings.ini file allows documents and CGI scripts to be stored in a directory other than the Documents Directory and CGI Directory. URLs with a (%-decoded) path beginning with url-path will be mapped to local files beginning with directory-path:

[aliases]
# url-path = directory-path
/image = /pub/image

A request for http://<your machine>/image/foo.gif would cause the server to return the file /pub/image/foo.gif. Note that if you include a trailing slash (/) on the url-path then the server will require a trailing slash in order to expand the alias. For example, if you use the alias:

[aliases]
# url-path = directory-path
/images/ = /pub/images/

then the URL http://<your machine>/images will not be aliased. The directory-path is appended to the Documents Directory of the Sambar Server unless a full path is supplied (i.e. c:/pub/images/).

Important! If mapping the "root" of a drive, you must include a trailing slash for both the alias and the root drive:

[aliases]
# url-path = directory-path
/dosc/ = c:/

[cgi-aliases] and [wincgi-aliases] work in the same manner as document aliases. So the following alias:

[cgi-aliases]
# url-path = directory-path
/cgi/ = c:/cgi-bin/

would result in the URL http://<your machine>/cgi/foo.pl being aliased to the script: c:/cgi-bin/foo.pl

IMPORTANT Aliases and CGI-aliases apply to all virtual hosts of the server. Also, an aliases entry cannot be both a document and CGI alias. See the modules documentation for information on running CGI entries for any document directory.

All mappings are compared with the "root" of the URI. So the URI /foo/images/ will not match the alias above. Lastly, aliases are sorted from longest to shortest for comparison so the alias /pub/local/ will be compared before the alias /pub/, regardless of the order in which the aliases were defined (and regardless of whether they are CGI or document aliases).

© 1998 Sambar Technologies. All rights reserved. Terms of Use.