📄 mod_actions.html
字号:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<meta name="keywords" content="Apache, 中文, 手册, 中文版, 中文手册, 中文版手册, 参考手册, 中文参考手册, 金步国" />
<meta name="description" content="Apache 2.2 中文版参考手册" />
<meta name="author" content="金步国" />
<link href="../style/css/manual-zip.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
<link href="../style/css/manual-zip-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
<link href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" />
<title>mod_actions - Apache 2.2 中文版参考手册</title>
</head>
<body><div id="page-header">
<p class="menu"><a href="../mod/index.html">模块索引</a> | <a href="../mod/directives.html">指令索引</a> | <a href="../faq/index.html">常见问题</a> | <a href="../glossary.html">词汇表</a> | <a href="../sitemap.html">站点导航</a></p><p class="apache">Apache HTTP Server 版本2.2</p><img alt="" src="../images/feather.gif" /></div>
<div class="up"><a href="./index.html"><img title="<-" alt="<-" src="../images/left.gif" /></a></div>
<div id="path"><a href="http://www.apache.org/">Apache</a> > <a href="http://httpd.apache.org/">HTTP Server</a> > <a href="http://httpd.apache.org/docs/">文档</a> > <a href="../index.html">版本2.2</a> > <a href="./index.html">模块</a></div>
<div id="translation-info"> <a href="../translator_announcement.html#thanks">致谢</a> | <a href="../translator_announcement.html#announcement">译者声明</a> | 本篇译者:<a href="mailto:csfrank@citiz.net">金步国</a> | 本篇译稿最后更新:2006年1月22日 | <a href="../translator_announcement.html#last_new">获取最新版本</a></div>
<div id="page-content"><div id="preamble"><h1>Apache模块 mod_actions</h1>
<table border="1" cellpadding="0" cellspacing="0" bordercolor="#AAAAAA" class="module">
<tr><th><a href="module-dict.html#Description">说明</a></th><td>基于媒体类型或请求方法,为执行CGI脚本而提供</td></tr>
<tr><th><a href="module-dict.html#Status">状态</a></th><td>基本(B)</td></tr>
<tr><th><a href="module-dict.html#ModuleIdentifier">模块名</a></th><td>actions_module</td></tr>
<tr><th><a href="module-dict.html#SourceFile">源文件</a></th><td>mod_actions.c</td></tr>
</table>
<h3>概述</h3>
<p>此模块有两个指令。<code class="directive"><a href="#action">Action</a></code>指令让你可以在对特定<a class="glossarylink" href="../glossary.html#mime-type" title="see glossary">MIME类型</a>文件请求的时候运行CGI脚本。<code class="directive"><a href="#script">Script</a></code>指令让你能够在使用特定请求方法的时候运行CGI脚本。这使得执行处理文件的CGI脚本更加容易。</p>
</div>
<div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
<div class="directive-section"><h2><a name="Action" id="Action">Action</a> <a name="action" id="action">指令</a></h2>
<table border="1" cellpadding="0" cellspacing="0" bordercolor="#AAAAAA" class="directive">
<tr><th><a href="directive-dict.html#Description">说明</a></th><td>针对特定的处理器或内容类型激活一个CGI脚本</td></tr>
<tr><th><a href="directive-dict.html#Syntax">语法</a></th><td><code>Action <var>action-type</var> <var>cgi-script</var> [virtual]</code></td></tr>
<tr><th><a href="directive-dict.html#Context">作用域</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
<tr><th><a href="directive-dict.html#Override">覆盖项</a></th><td>FileInfo</td></tr>
<tr><th><a href="directive-dict.html#Status">状态</a></th><td>基本(B)</td></tr>
<tr><th><a href="directive-dict.html#Module">模块</a></th><td>mod_actions</td></tr>
<tr><th><a href="directive-dict.html#Compatibility">兼容性</a></th><td><code>virtual</code>修饰词仅在 Apache 2.1 及之后的版本中可用</td></tr>
</table>
<p>这条指令添加一个当<var>action-type</var>被请求触发时会执行<var>cgi-script</var>的动作。<var>cgi-script</var>是一个URL路径,指向一个已经被用<code class="directive"><a href="../mod/mod_alias.html#scriptalias">ScriptAlias</a></code>或<code class="directive"><a href="../mod/mod_mime.html#addhandler">AddHandler</a></code>指令指定为CGI脚本的资源。<var>action-type</var>可以是一个<a href="../handler.html">处理器</a>或一个<a class="glossarylink" href="../glossary.html#mime-type" title="see glossary">MIME内容类型</a>。它使用标准的<code>PATH_INFO</code>和<code>PATH_TRANSLATED</code>环境变量来发送此URL和被请求内容的文件路径。用于该请求的处理器通过<code>REDIRECT_HANDLER</code>变量传递。</p>
<div class="example"><h3>例子</h3><p><code>
# 对特定MIME内容类型文件的请求<br />
Action image/gif /cgi-bin/images.cgi<br />
<br />
# 对于具有特定扩展名的文件<br />
AddHandler my-file-type .xyz<br />
Action my-file-type /cgi-bin/program.cgi<br />
</code></p></div>
<p>在第一个例子中,对于所有对MIME类型"<code>image/gif</code>"的请求都将被指定的CGI脚本<code>/cgi-bin/images.cgi</code>进行处理。</p>
<p>在第二个例子中,对于所有对具有扩展名"<code>.xyz</code>"的文件的请求都将被指定的CGI脚本<code>/cgi-bin/program.cgi</code>进行处理。</p>
<p>可选的<code>virtual</code>修饰词关闭了对所请求的文件是否真实存在的检查。这个修饰词很有用,比如希望将<code class="directive">Action</code>使用于虚拟位置的时候:</p>
<div class="example"><h3>示例</h3><p><code>
<Location /news><br />
<span class="indent">
SetHandler news-handler<br />
Action news-handler /cgi-bin/news.cgi virtual<br />
</span>
</Location>
</code></p></div>
<h3>参见</h3>
<ul>
<li><code class="directive"><a href="../mod/mod_mime.html#addhandler">AddHandler</a></code></li>
</ul>
</div>
<div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
<div class="directive-section"><h2><a name="Script" id="Script">Script</a> <a name="script" id="script">指令</a></h2>
<table border="1" cellpadding="0" cellspacing="0" bordercolor="#AAAAAA" class="directive">
<tr><th><a href="directive-dict.html#Description">说明</a></th><td>对特定的请求方法激活一个CGI脚本</td></tr>
<tr><th><a href="directive-dict.html#Syntax">语法</a></th><td><code>Script <var>method</var> <var>cgi-script</var></code></td></tr>
<tr><th><a href="directive-dict.html#Context">作用域</a></th><td>server config, virtual host, directory</td></tr>
<tr><th><a href="directive-dict.html#Status">状态</a></th><td>基本(B)</td></tr>
<tr><th><a href="directive-dict.html#Module">模块</a></th><td>mod_actions</td></tr>
</table>
<p>该指令添加一个当文件被<var>method</var>方法请求时会激活脚本<var>cgi-script</var>的动作。<var>cgi-script</var>是一个URL路径,指向一个已用<code class="directive"><a href="../mod/mod_alias.html#scriptalias">ScriptAlias</a></code>或<code class="directive"><a href="../mod/mod_mime.html#addhandler">AddHandler</a></code>指令指定为CGI脚本的资源。它使用标准的<code>PATH_INFO</code>和<code>PATH_TRANSLATED</code>环境变量来发送此URL和被请求内容的文件路径。</p>
<div class="note">可以使用任意的方法名称。<strong>方法名大小写敏感</strong>,因此 <code>Script PUT</code> 和 <code>Script put</code> 具有完全不同的结果。</div>
<p>注意,<code class="directive">Script</code>命令只定义了默认的动作。如果一个CGI脚本或其他能够内部处理此请求的资源被调用,就将这样做。同时注意对应<code>GET</code>方法的脚本只有在提供了查询参数的时候才会被调用(例如:"foo.html?hi")。否则,该请求将被正常处理。</p>
<div class="example"><h3>例子</h3><p><code>
# <ISINDEX>风格的搜索<br />
Script GET /cgi-bin/search<br />
<br />
# A CGI PUT 处理器<br />
Script PUT /~bob/put.cgi<br />
</code></p></div>
</div>
</div>
<div id="footer">
<p class="apache">本文允许自由使用、分发、转载,但必须保留译者署名;详见:<a href="../translator_announcement.html#announcement">译者声明</a>。</p>
<p class="menu"><a href="../mod/index.html">模块索引</a> | <a href="../mod/directives.html">指令索引</a> | <a href="../faq/index.html">常见问题</a> | <a href="../glossary.html">词汇表</a> | <a href="../sitemap.html">站点导航</a></p></div>
</body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -