Extra Path Information

Interestingly enough, you can pass information to your CGI program by adding extra information to the standard URL. If your CGI program is used for searching your site, for example, you can pass some information to specify which directory to search. The server gauges where the CGI program name ends; anything following is deemed "extra" and is stored in the environment variable PATH_INFO. The following HTML hyperlink will invoke a search script and tell it to search the /root/documents directory.

<A HREF="cgi-bin/search.pl/root/documents">
Search the Document Directory
</A>

This extra path information can be accessed through the PATH_INFO Environment Variable.

Everything after search.pl is the extra path. This extra path information can be accessed through the PATH_INFO environment variable. The PATH_TRANSLATED variable is also set, mapping the PATH_INFO to the document root (DOCUMENT_ROOT) directory (e.g., /root/documents).