Action
Actiontypecgi_scriptServer config, virtual host, directory, .htaccess
The cgi_script is applied to any file of
MIME or handler type matching type
whenever it is requested. This mechanism can be used in a number of
ways. For instance, it can be handy to put certain files through a
filter before they are served up on the Web. As a simple example,
suppose we wanted to keep all our .html files in
compressed format to save space and to decompress them on the fly as
they are retrieved. Apache happily does this. We make
site.filter a copy of
site.firs
t, except that the
httpd.conf file is as follows:
User webuser Group webgroup ServerName localhost DocumentRoot /usr/www/APACHE3/site.filter/htdocs ScriptAlias /cgi-bin /usr/www/APACHE3/cgi-bin AccessConfig /dev/null ResourceConfig /dev/null AddHandler peter-zipped-html zhtml Action peter-zipped-html /cgi-bin/unziphtml <Directory /usr/www/APACHE3/site.filter/htdocs> DirectoryIndex index.zhtml </Directory>
The points to notice are that:
AddHandlersets up a new handler with a name we invented,peter-zipped-html, and associates a file extension with it: zhtml (notice the absence of the period).Actionsets up a filter. For instance:Action peter-zipped-html /cgi-bin/unziphtml
means “apply the CGI script unziphtml to anything with the handler name
peter-zipped-html.”
The CGI script ... /cgi-bin/unziphtml contains the following:
#!/bin/sh echo "Content-Type: text/html" echo gzip -S .zhtml -d -c $PATH_TRANSLATED
This applies gzip with the ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access