2 <!DOCTYPE modulesynopsis SYSTEM "../style/modulesynopsis.dtd">
3 <?xml-stylesheet type="text/xsl" href="../style/manual.en.xsl"?>
4 <!-- $LastChangedRevision$ -->
7 Licensed to the Apache Software Foundation (ASF) under one or more
8 contributor license agreements. See the NOTICE file distributed with
9 this work for additional information regarding copyright ownership.
10 The ASF licenses this file to You under the Apache License, Version 2.0
11 (the "License"); you may not use this file except in compliance with
12 the License. You may obtain a copy of the License at
14 http://www.apache.org/licenses/LICENSE-2.0
16 Unless required by applicable law or agreed to in writing, software
17 distributed under the License is distributed on an "AS IS" BASIS,
18 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 See the License for the specific language governing permissions and
20 limitations under the License.
23 <modulesynopsis metafile="mod_actions.xml.meta">
25 <name>mod_actions</name>
27 <description>This module provides for executing CGI scripts based on
28 media type or request method.</description>
31 <sourcefile>mod_actions.c</sourcefile>
32 <identifier>actions_module</identifier>
35 <p>This module has two directives. The <directive
36 module="mod_actions">Action</directive> directive lets you run CGI
37 scripts whenever a file of a certain <glossary
38 ref="mime-type">MIME content type</glossary> is requested. The
39 <directive module="mod_actions">Script</directive> directive lets
40 you run CGI scripts whenever a particular method is used in a
41 request. This makes it much easier to execute scripts that process
44 <seealso><module>mod_cgi</module></seealso>
45 <seealso><a href="../howto/cgi.html">Dynamic Content with CGI</a></seealso>
46 <seealso><a href="../handler.html">Apache httpd's Handler Use</a></seealso>
50 <description>Activates a CGI script for a particular handler or
51 content-type</description>
52 <syntax>Action <var>action-type</var> <var>cgi-script</var> [virtual]</syntax>
54 <context>server config</context><context>virtual host</context>
55 <context>directory</context><context>.htaccess</context>
57 <override>FileInfo</override>
58 <compatibility>The <code>virtual</code> modifier and handler passing were
59 introduced in Apache 2.1</compatibility>
62 <p>This directive adds an action, which will activate
63 <var>cgi-script</var> when <var>action-type</var> is triggered by
64 the request. The <var>cgi-script</var> is the URL-path to a
65 resource that has been designated as a CGI script using <directive
66 module="mod_alias">ScriptAlias</directive> or <directive
67 module="mod_mime">AddHandler</directive>. The
68 <var>action-type</var> can be either a <a
69 href="../handler.html">handler</a> or a <glossary
70 ref="mime-type">MIME content type</glossary>. It sends the URL and
71 file path of the requested document using the standard CGI
72 <code>PATH_INFO</code> and <code>PATH_TRANSLATED</code>
73 environment variables. The handler used for the particular request
74 is passed using the <code>REDIRECT_HANDLER</code> variable.</p>
76 <example><title>Example: MIME type</title>
77 <highlight language="config">
78 # Requests for files of a particular MIME content type:
79 Action image/gif /cgi-bin/images.cgi
83 <p>In this example, requests for files with a MIME content
84 type of <code>image/gif</code> will be handled by the
85 specified cgi script <code>/cgi-bin/images.cgi</code>.</p>
88 <title>Example: File extension</title>
89 <highlight language="config">
90 # Files of a particular file extension
91 AddHandler my-file-type .xyz
92 Action my-file-type /cgi-bin/program.cgi
95 <p>In this example, requests for files with a file extension of
96 <code>.xyz</code> are handled by the specified cgi script
97 <code>/cgi-bin/program.cgi</code>.</p>
99 <p>The optional <code>virtual</code> modifier turns off the check
100 whether the requested file really exists. This is useful, for example,
101 if you want to use the <directive>Action</directive> directive in
102 virtual locations.</p>
104 <highlight language="config">
105 <Location /news>
106 SetHandler news-handler
107 Action news-handler /cgi-bin/news.cgi virtual
112 <seealso><directive module="mod_mime">AddHandler</directive></seealso>
117 <description>Activates a CGI script for a particular request
118 method.</description>
119 <syntax>Script <var>method</var> <var>cgi-script</var></syntax>
121 <context>server config</context><context>virtual host</context>
122 <context>directory</context></contextlist>
124 <p>This directive adds an action, which will activate
125 <var>cgi-script</var> when a file is requested using the method of
126 <var>method</var>. The <var>cgi-script</var> is the URL-path to a
127 resource that has been designated as a CGI script using <directive
128 module="mod_alias">ScriptAlias</directive> or <directive
129 module="mod_mime">AddHandler</directive>. The URL and
130 file path of the requested document is sent using the standard CGI
131 <code>PATH_INFO</code> and <code>PATH_TRANSLATED</code> environment
135 Any arbitrary method name may be used. <strong>Method names are
136 case-sensitive</strong>, so <code>Script PUT</code> and
137 <code>Script put</code> have two entirely different
141 <p>Note that the <directive>Script</directive> command defines default
142 actions only. If a CGI script is called, or some other resource that is
143 capable of handling the requested method internally, it will do
144 so. Also note that <directive>Script</directive> with a method of
145 <code>GET</code> will only be called if there are query arguments present
146 (<em>e.g.</em>, foo.html?hi). Otherwise, the request will
147 proceed normally.</p>
149 <highlight language="config">
150 # All GET requests go here
151 Script GET /cgi-bin/search
154 Script PUT /~bob/put.cgi