If your Apache Config file invokes CGI processing with the directive
ScriptAlias
, you can construct links in your HTML
that have extra data passed with them as if they were directory names
passed in the Environment variable PATH_INFO
. For
instance:
... <A HREF="/cgi-bin/script2_html/whole_database">Click here to see whole database</A> ...
When the user clicks on this link she invokes
script2_html
and makes available to it the
Environment variable PATH_INFO
, containing the
string /whole_database
. We can test this in our
Perl script with this:
if($ENV{'PATH_INFO'} eq '/whole_database') { #do something }
Our script can then make a decision about what to do next on the
basis of this information. The same mechanism is available with the
HTML FORM
ACTION
attribute. We
might set up a form in our HTML with the command:
<FORM METHOD='POST' ACTION="/cgi-bin/script2_html/receipts">
As previously, /receipts
will turn up in
PATH_INFO
, and your script knows which form sent
the data and can go to the appropriate subroutine to deal with it.
What happens inside Apache is that the
URI — /cgi-bin/script2_html/receipts — is
parsed from right to left, looking for a filename, which does not
have to be a CGI script. The material to the right of the filename is
passed in PATH_INFO
.