Apache The Definitive Guide, 3rd EditionApache: The Definitive GuideSearch this book

16.7. Handlers

A handler is a piece of code built into Apache that performs certain actions when a file with a particular MIME or handler type is called. For example, a file with the handler type cgi-script needs to be executed as a CGI script. This is illustrated in ... /site.filter.

Apache has a number of handlers built in, and others can be added with the Actions command (see the next section). The built-in handlers are as follows:

send-as-is
Sends the file as is, with HTTP headers (mod_asis).

cgi-script
Executes the file (mod_cgi). Note that Options ExecCGI must also be set.

imap-file
Uses the file as an imagemap (mod_imap).

server-info
Gets the server's configuration (mod_info).

server-status
Gets the server's current status (mod_status).

server-parsed
Parses server-side includes (mod_include). Note that Options Includes must also be set.

type-map
Parses the file as a type map file for content negotiation (mod_negotiation).

isapi-isa ( Win32 only)
Figure

Causes ISA DLLs placed in the document root directory to be loaded when their URLs are accessed. Options ExecCGI must be active in the directory that contains the ISA. Check the Apache documentation, since this feature is under development (mod_isapi).

The corresponding directives follow.

AddHandler

AddHandler handler-name extension1 extension2 ...
Server config, virtual host, directory, .htaccess

AddHandler wakes up an existing handler and maps the filename(s) extension1, etc., to handler-name. You might specify the following in your Config file:

AddHandler cgi-script cgi bzq

From then on, any file with the extension .cgi or .bzq would be treated as an executable CGI script.

SetHandler

SetHandler handler-name
directory, .htaccess

This does the same thing as AddHandler, but applies the transformation specified by handler-name to all files in the <Directory>, <Location>, or <Files> section in which it is placed or in the .htaccess directory. For instance, in Chapter 10, we write:

<Location /status>
<Limit get>
order deny,allow
allow from 192.168.123.1
deny from all
</Limit>
SetHandler server-status
</Location>
RemoveHandler

RemoveHandler extension [extension] ...
directory, .htaccess
RemoveHandler is only available in Apache 1.3.4 and later. 

The RemoveHandler directive removes any handler associations for files with the given extensions. This allows .htaccess files in subdirectories to undo any associations inherited from parent directories or the server config files. An example of its use might be:

/foo/.htaccess: 
    AddHandler server-parsed .html 
/foo/bar/.htaccess: 
    RemoveHandler .html 

This has the effect of treating .html files in the /foo/bar directory as normal files, rather than as candidates for parsing (see the mod_include module).

The extension argument is case insensitive and can be specified with or without a leading dot.



Library Navigation Links

Copyright © 2003 O'Reilly & Associates. All rights reserved.