⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mod_alias.html

📁 这个是我在web培训时老师提供的手册
💻 HTML
📖 第 1 页 / 共 2 页
字号:
      Redirect /service http://foo2.example.com/service
    </code></p></div>

    <p>如果客户端请求"http://example.com/service/foo.txt",则会被重定向到"http://foo2.example.com/service/foo.txt"。因为仅匹配完整路径,所以上述例子不会匹配"http://example.com/servicefoo.txt"请求。对于使用正则表达式的匹配,请参见<code class="directive"><a href="#redirectmatch">RedirectMatch</a></code>指令。</p>


	<div class="note"><h3>注意</h3> <p>重定向指令总是优先于Alias和ScriptAlias指令,而无论他们在配置文件中的顺序如何。</p></div>

    <p>如果没有指定<var>status</var>参数,则重定向是"临时的"(HTTP status 302)。也就是对客户端来说,此资源的位置变动是临时性的。此<var>status</var>参数可以返回以下HTTP状态码:</p>

    <dl>
      <dt>permanent</dt>

      <dd>返回一个永久性重定向状态码(301),表示此资源的位置变动是永久性的。</dd>

      <dt>temp</dt>

      <dd>返回一个临时性重定向状态码(302),这是默认值。</dd>

      <dt>seeother</dt>

      <dd>返回一个"参见"状态码(303),表示此资源已经被替代。</dd>

      <dt>gone</dt>

      <dd>返回一个"已废弃"状态码(410),表示此资源已经被永久性地删除了。如果指定了这个状态码,则<var>URL</var>参数将被忽略。</dd>
    </dl>

    <p><var>status</var>可以被指定为数字状态以返回其他状态码。如果此状态在300-399之间,则必须提供<var>URL</var>参数,否则将被忽略。注意,此状态码必须是Apache已知的(参见http_protocol.c中的<code>send_error_response</code>函数)。</p>

    <div class="example"><h3>示例:</h3><p><code>
      Redirect permanent /one http://example.com/two<br />
      Redirect 303 /three http://example.com/other
    </code></p></div>


</div>
<div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
<div class="directive-section"><h2><a name="RedirectMatch" id="RedirectMatch">RedirectMatch</a> <a name="redirectmatch" id="redirectmatch">指令</a></h2>
<table border="1" cellpadding="0" cellspacing="0" bordercolor="#AAAAAA" class="directive">
<tr><th><a href="directive-dict.html#Description">说明</a></th><td>基于正则表达式匹配对当前的URL发送一个外部重定向</td></tr>
<tr><th><a href="directive-dict.html#Syntax">语法</a></th><td><code>RedirectMatch [<var>status</var>] <var>regex</var> <var>URL</var></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_alias</td></tr>
</table>
    <p>该指令与<code class="directive"><a href="#redirect">Redirect</a></code>等效,但是它使用了标准的<a class="glossarylink" href="../glossary.html#regex" title="see glossary">正则表达式</a>,而不是简单的前缀匹配。如果<var>regex</var>与URL-path相匹配,则服务器会把所匹配的括弧中的字符串替换到该指令所指定的目标字符串中,并视之为一个文件名。例如,重定向所有GIF文件到另一个服务器上同名的JPEG文件,可以:</p>

    <div class="example"><p><code>
      RedirectMatch (.*)\.gif$ http://www.anotherserver.com$1.jpg
    </code></p></div>

</div>
<div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
<div class="directive-section"><h2><a name="RedirectPermanent" id="RedirectPermanent">RedirectPermanent</a> <a name="redirectpermanent" id="redirectpermanent">指令</a></h2>
<table border="1" cellpadding="0" cellspacing="0" bordercolor="#AAAAAA" class="directive">
<tr><th><a href="directive-dict.html#Description">说明</a></th><td>发送一个外部永久重定向使客户端重定向到一个不同的URL</td></tr>
<tr><th><a href="directive-dict.html#Syntax">语法</a></th><td><code>RedirectPermanent <var>URL-path</var> <var>URL</var></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_alias</td></tr>
</table>
    <p>此指令告知客户端此重定向是永久性的(status 301)。与"<code>Redirect permanent</code>"等效。</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="RedirectTemp" id="RedirectTemp">RedirectTemp</a> <a name="redirecttemp" id="redirecttemp">指令</a></h2>
<table border="1" cellpadding="0" cellspacing="0" bordercolor="#AAAAAA" class="directive">
<tr><th><a href="directive-dict.html#Description">说明</a></th><td>发送一个外部临时重定向使客户端重定向到一个不同的URL</td></tr>
<tr><th><a href="directive-dict.html#Syntax">语法</a></th><td><code>RedirectTemp <var>URL-path</var> <var>URL</var></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_alias</td></tr>
</table>
    <p>此指令告知客户端此重定向只是临时性的(status 302)。与"<code>Redirect temp</code>"等效。</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="ScriptAlias" id="ScriptAlias">ScriptAlias</a> <a name="scriptalias" id="scriptalias">指令</a></h2>
<table border="1" cellpadding="0" cellspacing="0" bordercolor="#AAAAAA" class="directive">
<tr><th><a href="directive-dict.html#Description">说明</a></th><td>映射一个URL到文件系统并视之为CGI脚本</td></tr>
<tr><th><a href="directive-dict.html#Syntax">语法</a></th><td><code>ScriptAlias <var>URL-path</var> <var>file-path</var>|<var>directory-path</var></code></td></tr>
<tr><th><a href="directive-dict.html#Context">作用域</a></th><td>server config, virtual host</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_alias</td></tr>
</table>
    <p><code class="directive">ScriptAlias</code>指令的行为与<code class="directive"><a href="#alias">Alias</a></code>指令相同,但同时它又标明此目录中含有应该由cgi-script处理器处理的CGI脚本。以<var>URL-path</var>开头的(%已解码的)的URL会被映射到由第二个参数指定的具有完整路径名的本地文件系统中的脚本。</p>

    <div class="example"><h3>示例:</h3><p><code>
      ScriptAlias /cgi-bin/ /web/cgi-bin/
    </code></p></div>

    <p>对<code>http://myserver/cgi-bin/foo</code>的请求会引导服务器执行<code>/web/cgi-bin/foo</code>脚本。</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="ScriptAliasMatch" id="ScriptAliasMatch">ScriptAliasMatch</a> <a name="scriptaliasmatch" id="scriptaliasmatch">指令</a></h2>
<table border="1" cellpadding="0" cellspacing="0" bordercolor="#AAAAAA" class="directive">
<tr><th><a href="directive-dict.html#Description">说明</a></th><td>使用正则表达式映射一个URL到文件系统并视之为CGI脚本</td></tr>
<tr><th><a href="directive-dict.html#Syntax">语法</a></th><td><code>ScriptAliasMatch <var>regex</var> <var>file-path</var>|<var>directory-path</var></code></td></tr>
<tr><th><a href="directive-dict.html#Context">作用域</a></th><td>server config, virtual host</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_alias</td></tr>
</table>
    <p>该指令与<code class="directive"><a href="#scriptalias">ScriptAlias</a></code>等效,但是它使用了标准的<a class="glossarylink" href="../glossary.html#regex" title="see glossary">正则表达式</a>,而不是简单的前缀匹配。如果<var>regex</var>与URL-path相匹配,则服务器会把所匹配的括弧中的字符串替换到该指令所指定的目标字符串中,并视之为一个文件名。例如,要使用标准的<code>/cgi-bin</code> ,可以:</p>

    <div class="example"><p><code>
      ScriptAliasMatch ^/cgi-bin(.*) /usr/local/apache/cgi-bin$1
    </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 + -