Associating Scripts with HTTP Methods and MIME Types


# Processing all GIF images through a CGI script # before serving them Action image/gif /cgi-bin/filter.cgi # Associating specific HTTP methods with a CGI # script Script PUT /cgi-bin/upload.cgi


In addition to the directives mentioned in the previous section, Apache provides directives that simplify associating specific MIME types, file extensions, or even specific HTTP methods with a particular CGI. The mod_actions module, included in the base distribution and compiled by default, provides the Action and Script directives, shown in this example:

  • The Action directive accepts two arguments. The first argument is a handler or a MIME content type; the second points to the CGI program to handle the request.

  • The Script directive associates certain HTTP request methods with a CGI program.

The information about the original requested document is passed to the CGI via the PATH_INFO (document URL) and PATH_TRANSLATED (document path) environment variables.

As with the example from the previous section, the directory containing the destination CGI must be marked as allowing CGI execution with either a ScriptAlias directive or the ExecCGI parameter to the Options directive.




Apache(c) Phrase Book(c) Essential Code and Commands
Apache Phrasebook
ISBN: 0672328364
EAN: 2147483647
Year: 2006
Pages: 254

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net