github.com/krum110487/go-htaccess@v0.0.0-20240316004156-60641c8e7598/tests/data/apache_2_2_34/manual/mod/mod_alias.html.en (about)

     1  <?xml version="1.0" encoding="ISO-8859-1"?>
     2  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
     3  <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head>
     4  <meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type" />
     5  <!--
     6          XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
     7                This file is generated from xml source: DO NOT EDIT
     8          XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
     9        -->
    10  <title>mod_alias - Apache HTTP Server Version 2.2</title>
    11  <link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
    12  <link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
    13  <link href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link rel="stylesheet" type="text/css" href="../style/css/prettify.css" />
    14  <script src="../style/scripts/prettify.min.js" type="text/javascript">
    15  </script>
    16  
    17  <link href="../images/favicon.ico" rel="shortcut icon" /><link href="http://httpd.apache.org/docs/current/mod/mod_alias.html" rel="canonical" /></head>
    18  <body>
    19  <div id="page-header">
    20  <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p>
    21  <p class="apache">Apache HTTP Server Version 2.2</p>
    22  <img alt="" src="../images/feather.gif" /></div>
    23  <div class="up"><a href="./"><img title="&lt;-" alt="&lt;-" src="../images/left.gif" /></a></div>
    24  <div id="path">
    25  <a href="http://www.apache.org/">Apache</a> &gt; <a href="http://httpd.apache.org/">HTTP Server</a> &gt; <a href="http://httpd.apache.org/docs/">Documentation</a> &gt; <a href="../">Version 2.2</a> &gt; <a href="./">Modules</a></div>
    26  <div id="page-content">
    27  <div class="retired"><h4>Please note</h4>
    28              <p> This document refers to a legacy release (<strong>2.2</strong>) of Apache httpd. The active release (<strong>2.4</strong>) is documented <a href="http://httpd.apache.org/docs/current">here</a>. If you have not already upgraded, please follow <a href="http://httpd.apache.org/docs/current/upgrading.html">this link</a> for more information.</p>
    29          <p>You may follow <a href="http://httpd.apache.org/docs/current/mod/mod_alias.html">this link</a> to go to the current version of this document.</p></div><div id="preamble"><h1>Apache Module mod_alias</h1>
    30  <div class="toplang">
    31  <p><span>Available Languages: </span><a href="../en/mod/mod_alias.html" title="English">&nbsp;en&nbsp;</a> |
    32  <a href="../ja/mod/mod_alias.html" hreflang="ja" rel="alternate" title="Japanese">&nbsp;ja&nbsp;</a> |
    33  <a href="../ko/mod/mod_alias.html" hreflang="ko" rel="alternate" title="Korean">&nbsp;ko&nbsp;</a> |
    34  <a href="../tr/mod/mod_alias.html" hreflang="tr" rel="alternate" title="Türkçe">&nbsp;tr&nbsp;</a></p>
    35  </div>
    36  <table class="module"><tr><th><a href="module-dict.html#Description">Description:</a></th><td>Provides for mapping different parts of the host
    37      filesystem in the document tree and for URL redirection</td></tr>
    38  <tr><th><a href="module-dict.html#Status">Status:</a></th><td>Base</td></tr>
    39  <tr><th><a href="module-dict.html#ModuleIdentifier">Module Identifier:</a></th><td>alias_module</td></tr>
    40  <tr><th><a href="module-dict.html#SourceFile">Source File:</a></th><td>mod_alias.c</td></tr></table>
    41  <h3>Summary</h3>
    42  
    43      <p>The directives contained in this module allow for manipulation
    44      and control of URLs as requests arrive at the server. The
    45      <code class="directive"><a href="#alias">Alias</a></code> and <code class="directive"><a href="#scriptalias">ScriptAlias</a></code> directives are used to
    46      map between URLs and filesystem paths.  This allows for content
    47      which is not directly under the <code class="directive"><a href="../mod/core.html#documentroot">DocumentRoot</a></code> served as part of the web
    48      document tree. The <code class="directive"><a href="#scriptalias">ScriptAlias</a></code> directive has the
    49      additional effect of marking the target directory as containing
    50      only CGI scripts.</p>
    51  
    52      <p>The <code class="directive"><a href="#redirect">Redirect</a></code>
    53      directives are used to instruct clients to make a new request with
    54      a different URL. They are often used when a resource has moved to
    55      a new location.</p>
    56  
    57      <p><code class="module"><a href="../mod/mod_alias.html">mod_alias</a></code> is designed to handle simple URL
    58      manipulation tasks.  For more complicated tasks such as
    59      manipulating the query string, use the tools provided by
    60      <code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code>.</p>
    61  
    62  </div>
    63  <div id="quickview"><h3>Topics</h3>
    64  <ul id="topics">
    65  <li><img alt="" src="../images/down.gif" /> <a href="#order">Order of Processing</a></li>
    66  </ul><h3 class="directives">Directives</h3>
    67  <ul id="toc">
    68  <li><img alt="" src="../images/down.gif" /> <a href="#alias">Alias</a></li>
    69  <li><img alt="" src="../images/down.gif" /> <a href="#aliasmatch">AliasMatch</a></li>
    70  <li><img alt="" src="../images/down.gif" /> <a href="#redirect">Redirect</a></li>
    71  <li><img alt="" src="../images/down.gif" /> <a href="#redirectmatch">RedirectMatch</a></li>
    72  <li><img alt="" src="../images/down.gif" /> <a href="#redirectpermanent">RedirectPermanent</a></li>
    73  <li><img alt="" src="../images/down.gif" /> <a href="#redirecttemp">RedirectTemp</a></li>
    74  <li><img alt="" src="../images/down.gif" /> <a href="#scriptalias">ScriptAlias</a></li>
    75  <li><img alt="" src="../images/down.gif" /> <a href="#scriptaliasmatch">ScriptAliasMatch</a></li>
    76  </ul>
    77  <h3>See also</h3>
    78  <ul class="seealso">
    79  <li><code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code></li>
    80  <li><a href="../urlmapping.html">Mapping URLs to the filesystem</a></li>
    81  </ul><ul class="seealso"><li><a href="#comments_section">Comments</a></li></ul></div>
    82  <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
    83  <div class="section">
    84  <h2><a name="order" id="order">Order of Processing</a></h2>
    85  
    86      <p>Aliases and Redirects occurring in different contexts are processed
    87      like other directives according to standard <a href="../sections.html#mergin">merging rules</a>.  But when multiple
    88      Aliases or Redirects occur in the same context (for example, in the
    89      same <code class="directive"><a href="../mod/core.html#virtualhost">&lt;VirtualHost&gt;</a></code>
    90      section) they are processed in a particular order.</p>
    91  
    92      <p>First, all Redirects are processed before Aliases are processed,
    93      and therefore a request that matches a <code class="directive"><a href="#redirect">Redirect</a></code> or <code class="directive"><a href="#redirectmatch">RedirectMatch</a></code> will never have Aliases
    94      applied.  Second, the Aliases and Redirects are processed in the order
    95      they appear in the configuration files, with the first match taking
    96      precedence.</p>
    97  
    98      <p>For this reason, when two or more of these directives apply to the
    99      same sub-path, you must list the most specific path first in order for
   100      all the directives to have an effect.  For example, the following
   101      configuration will work as expected:</p>
   102  
   103      <div class="example"><p><code>
   104      Alias /foo/bar /baz<br />
   105      Alias /foo /gaq
   106      </code></p></div>
   107  
   108      <p>But if the above two directives were reversed in order, the
   109      <code>/foo</code> <code class="directive"><a href="#alias">Alias</a></code>
   110      would always match before the <code>/foo/bar</code> <code class="directive"><a href="#alias">Alias</a></code>, so the latter directive would be
   111      ignored.</p>
   112  
   113  </div>
   114  <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
   115  <div class="directive-section"><h2><a name="Alias" id="Alias">Alias</a> <a name="alias" id="alias">Directive</a></h2>
   116  <table class="directive">
   117  <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Maps URLs to filesystem locations</td></tr>
   118  <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>Alias <var>URL-path</var>
   119  <var>file-path</var>|<var>directory-path</var></code></td></tr>
   120  <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
   121  <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
   122  <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_alias</td></tr>
   123  </table>
   124  
   125      <p>The <code class="directive">Alias</code> directive allows documents to
   126      be stored in the local filesystem other than under the
   127      <code class="directive"><a href="../mod/core.html#documentroot">DocumentRoot</a></code>. URLs with a
   128      (%-decoded) path beginning with <var>URL-path</var> will be mapped
   129      to local files beginning with <var>directory-path</var>.  The
   130      <var>URL-path</var> is case-sensitive, even on case-insensitive
   131      file systems.</p>
   132  
   133      <div class="example"><h3>Example:</h3><p><code>
   134        Alias /image /ftp/pub/image
   135      </code></p></div>
   136  
   137      <p>A request for <code>http://example.com/image/foo.gif</code> would cause
   138      the server to return the file <code>/ftp/pub/image/foo.gif</code>.  Only
   139      complete path segments are matched, so the above alias would not match a
   140      request for <code>http://example.com/imagefoo.gif</code>.  For more complex
   141      matching using regular expressions, see the <code class="directive"><a href="#aliasmatch">AliasMatch</a></code> directive.</p>
   142  
   143      <p>Note that if you include a trailing / on the
   144      <var>URL-path</var> then the server will require a trailing / in
   145      order to expand the alias. That is, if you use</p>
   146  
   147      <div class="example"><p><code>
   148          Alias /icons/ /usr/local/apache/icons/
   149      </code></p></div>
   150  
   151      <p>then the URL <code>/icons</code> will not be aliased, as it lacks
   152      that trailing /. Likewise, if you omit the slash on the
   153      <var>URL-path</var> then you must also omit it from the
   154      <var>file-path</var>.</p>
   155  
   156      <p>Note that you may need to specify additional <code class="directive"><a href="../mod/core.html#directory">&lt;Directory&gt;</a></code> sections which
   157      cover the <em>destination</em> of aliases.  Aliasing occurs before
   158      <code class="directive"><a href="../mod/core.html#directory">&lt;Directory&gt;</a></code> sections
   159      are checked, so only the destination of aliases are affected.
   160      (Note however <code class="directive"><a href="../mod/core.html#location">&lt;Location&gt;</a></code>
   161      sections are run through once before aliases are performed, so
   162      they will apply.)</p>
   163  
   164      <p>In particular, if you are creating an <code>Alias</code> to a
   165      directory outside of your <code class="directive"><a href="../mod/core.html#documentroot">DocumentRoot</a></code>, you may need to explicitly
   166      permit access to the target directory.</p>
   167  
   168      <div class="example"><h3>Example:</h3><p><code>
   169          Alias /image /ftp/pub/image<br />
   170          &lt;Directory /ftp/pub/image&gt;<br />
   171          <span class="indent">
   172              Order allow,deny<br />
   173              Allow from all<br />
   174          </span>
   175          &lt;/Directory&gt;
   176      </code></p></div>
   177  
   178      <p>Any number of slashes in the <var>URL-path</var> parameter
   179      matches any number of slashes in the requested URL-path.</p>
   180  
   181  
   182  </div>
   183  <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
   184  <div class="directive-section"><h2><a name="AliasMatch" id="AliasMatch">AliasMatch</a> <a name="aliasmatch" id="aliasmatch">Directive</a></h2>
   185  <table class="directive">
   186  <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Maps URLs to filesystem locations using regular
   187  expressions</td></tr>
   188  <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>AliasMatch <var>regex</var>
   189  <var>file-path</var>|<var>directory-path</var></code></td></tr>
   190  <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
   191  <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
   192  <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_alias</td></tr>
   193  </table>
   194      <p>This directive is equivalent to <code class="directive"><a href="#alias">Alias</a></code>, but makes use of
   195      <a class="glossarylink" href="../glossary.html#regex" title="see glossary">regular expressions</a>,
   196      instead of simple prefix matching. The
   197      supplied regular expression is matched against the URL-path, and
   198      if it matches, the server will substitute any parenthesized
   199      matches into the given string and use it as a filename. For
   200      example, to activate the <code>/icons</code> directory, one might
   201      use:</p>
   202  
   203      <div class="example"><p><code>
   204        AliasMatch ^/icons(.*) /usr/local/apache/icons$1
   205      </code></p></div>
   206  
   207      <p>The full range of <a class="glossarylink" href="../glossary.html#regex" title="see glossary">regular expression</a>
   208      power is available.  For example,
   209      it is possible to construct an alias with case-insensitive
   210      matching of the URL-path:</p>
   211  
   212      <div class="example"><p><code>
   213        AliasMatch (?i)^/image(.*) /ftp/pub/image$1
   214      </code></p></div>
   215  
   216      <p>One subtle difference
   217      between <code class="directive"><a href="#alias">Alias</a></code>
   218      and <code class="directive"><a href="#aliasmatch">AliasMatch</a></code> is
   219      that <code class="directive"><a href="#alias">Alias</a></code> will
   220      automatically copy any additional part of the URI, past the part
   221      that matched, onto the end of the file path on the right side,
   222      while <code class="directive"><a href="#aliasmatch">AliasMatch</a></code> will
   223      not.  This means that in almost all cases, you will want the
   224      regular expression to match the entire request URI from beginning
   225      to end, and to use substitution on the right side.</p>
   226  
   227      <p>In other words, just changing 
   228      <code class="directive"><a href="#alias">Alias</a></code> to
   229      <code class="directive"><a href="#aliasmatch">AliasMatch</a></code> will not
   230      have the same effect.  At a minimum, you need to
   231      add <code>^</code> to the beginning of the regular expression
   232      and add <code>(.*)$</code> to the end, and add <code>$1</code> to
   233      the end of the replacement.</p>
   234  
   235      <p>For example, suppose you want to replace this with AliasMatch:</p>
   236  
   237      <div class="example"><p><code>
   238        Alias /image/ /ftp/pub/image/
   239      </code></p></div>
   240  
   241      <p>This is NOT equivalent - don't do this!  This will send all
   242      requests that have /image/ anywhere in them to /ftp/pub/image/:</p>
   243  
   244      <div class="example"><p><code>
   245        AliasMatch /image/ /ftp/pub/image/
   246      </code></p></div>
   247  
   248      <p>This is what you need to get the same effect:</p>
   249  
   250      <div class="example"><p><code>
   251        AliasMatch ^/image/(.*)$ /ftp/pub/image/$1
   252      </code></p></div>
   253  
   254      <p>Of course, there's no point in
   255      using <code class="directive"><a href="#aliasmatch">AliasMatch</a></code>
   256      where <code class="directive"><a href="#alias">Alias</a></code> would
   257      work.  <code class="directive"><a href="#aliasmatch">AliasMatch</a></code> lets
   258      you do more complicated things.  For example, you could
   259      serve different kinds of files from different directories:</p>
   260  
   261      <div class="example"><p><code>
   262        AliasMatch ^/image/(.*)\.jpg$ /files/jpg.images/$1.jpg<br />
   263        AliasMatch ^/image/(.*)\.gif$ /files/gif.images/$1.gif
   264      </code></p></div>
   265  
   266      <p>Multiple leading slashes in the requested URL are discarded
   267         by the server before directives from this module compares
   268         against the requested URL-path.
   269      </p>
   270  
   271  
   272  </div>
   273  <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
   274  <div class="directive-section"><h2><a name="Redirect" id="Redirect">Redirect</a> <a name="redirect" id="redirect">Directive</a></h2>
   275  <table class="directive">
   276  <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Sends an external redirect asking the client to fetch
   277  a different URL</td></tr>
   278  <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>Redirect [<var>status</var>] <var>URL-path</var>
   279  <var>URL</var></code></td></tr>
   280  <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
   281  <tr><th><a href="directive-dict.html#Override">Override:</a></th><td>FileInfo</td></tr>
   282  <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
   283  <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_alias</td></tr>
   284  <tr><th><a href="directive-dict.html#Compatibility">Compatibility:</a></th><td>Support for specifying a URL-path as the final argument was 
   285  added in Apache HTTP Server 2.2.6</td></tr>
   286  </table>
   287      <p>The Redirect directive maps an old URL into a new one by asking
   288      the client to refetch the resource at the new location.</p>
   289  
   290      <p>The old <em>URL-path</em> is a case-sensitive (%-decoded) path
   291      beginning with a slash.  A relative path is not allowed.  The new
   292      <em>URL</em> should be an absolute URL beginning with a scheme and
   293      hostname.  In Apache HTTP Server 2.2.6 and later, a URL-path beginning 
   294      with a slash may also be used, in which case the scheme and hostname 
   295      of the current server will be added.</p>
   296  
   297      <p>Then any request beginning with <em>URL-path</em> will return a
   298      redirect request to the client at the location of the target
   299      <em>URL</em>.  Additional path information beyond the matched
   300      <em>URL-path</em> will be appended to the target URL.</p>
   301  
   302      <div class="example"><h3>Example:</h3><p><code>
   303        Redirect /service http://foo2.example.com/service
   304      </code></p></div>
   305  
   306      <p>If the client requests <code>http://example.com/service/foo.txt</code>,
   307      it will be told to access
   308      <code>http://foo2.example.com/service/foo.txt</code>
   309      instead.  Only complete path segments are matched, so the above
   310      example would not match a request for
   311      <code>http://example.com/servicefoo.txt</code>.  For more complex matching
   312      using regular expressions, see the <code class="directive"><a href="#redirectmatch">RedirectMatch</a></code> directive.</p>
   313  
   314  
   315      <div class="note"><h3>Note</h3>
   316      <p>Redirect directives take precedence over
   317      Alias and ScriptAlias directives, irrespective of their ordering in
   318      the configuration file.</p></div>
   319  
   320      <p>If no <var>status</var> argument is given, the redirect will
   321      be "temporary" (HTTP status 302). This indicates to the client
   322      that the resource has moved temporarily. The <var>status</var>
   323      argument can be used to return other HTTP status codes:</p>
   324  
   325      <dl>
   326        <dt>permanent</dt>
   327  
   328        <dd>Returns a permanent redirect status (301) indicating that
   329        the resource has moved permanently.</dd>
   330  
   331        <dt>temp</dt>
   332  
   333        <dd>Returns a temporary redirect status (302). This is the
   334        default.</dd>
   335  
   336        <dt>seeother</dt>
   337  
   338        <dd>Returns a "See Other" status (303) indicating that the
   339        resource has been replaced.</dd>
   340  
   341        <dt>gone</dt>
   342  
   343        <dd>Returns a "Gone" status (410) indicating that the
   344        resource has been permanently removed. When this status is
   345        used the <var>URL</var> argument should be omitted.</dd>
   346      </dl>
   347  
   348      <p>Other status codes can be returned by giving the numeric
   349      status code as the value of <var>status</var>. If the status is
   350      between 300 and 399, the <var>URL</var> argument must be present,
   351      otherwise it must be omitted. Note that the status must be
   352      known to the Apache code (see the function
   353      <code>send_error_response</code> in http_protocol.c).</p>
   354  
   355      <div class="example"><h3>Example:</h3><p><code>
   356        Redirect permanent /one http://example.com/two<br />
   357        Redirect 303 /three http://example.com/other
   358      </code></p></div>
   359  
   360  
   361  </div>
   362  <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
   363  <div class="directive-section"><h2><a name="RedirectMatch" id="RedirectMatch">RedirectMatch</a> <a name="redirectmatch" id="redirectmatch">Directive</a></h2>
   364  <table class="directive">
   365  <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Sends an external redirect based on a regular expression match
   366  of the current URL</td></tr>
   367  <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RedirectMatch [<var>status</var>] <var>regex</var>
   368  <var>URL</var></code></td></tr>
   369  <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
   370  <tr><th><a href="directive-dict.html#Override">Override:</a></th><td>FileInfo</td></tr>
   371  <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
   372  <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_alias</td></tr>
   373  </table>
   374      <p>This directive is equivalent to <code class="directive"><a href="#redirect">Redirect</a></code>, but makes use of
   375      <a class="glossarylink" href="../glossary.html#regex" title="see glossary">regular expressions</a>,
   376      instead of simple prefix matching. The
   377      supplied regular expression is matched against the URL-path, and
   378      if it matches, the server will substitute any parenthesized
   379      matches into the given string and use it as a filename. For
   380      example, to redirect all GIF files to like-named JPEG files on
   381      another server, one might use:</p>
   382  
   383      <div class="example"><p><code>
   384        RedirectMatch (.*)\.gif$ http://www.anotherserver.com$1.jpg
   385      </code></p></div>
   386  
   387  </div>
   388  <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
   389  <div class="directive-section"><h2><a name="RedirectPermanent" id="RedirectPermanent">RedirectPermanent</a> <a name="redirectpermanent" id="redirectpermanent">Directive</a></h2>
   390  <table class="directive">
   391  <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Sends an external permanent redirect asking the client to fetch
   392  a different URL</td></tr>
   393  <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RedirectPermanent <var>URL-path</var> <var>URL</var></code></td></tr>
   394  <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
   395  <tr><th><a href="directive-dict.html#Override">Override:</a></th><td>FileInfo</td></tr>
   396  <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
   397  <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_alias</td></tr>
   398  </table>
   399      <p>This directive makes the client know that the Redirect is
   400      permanent (status 301). Exactly equivalent to <code>Redirect
   401      permanent</code>.</p>
   402  
   403  </div>
   404  <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
   405  <div class="directive-section"><h2><a name="RedirectTemp" id="RedirectTemp">RedirectTemp</a> <a name="redirecttemp" id="redirecttemp">Directive</a></h2>
   406  <table class="directive">
   407  <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Sends an external temporary redirect asking the client to fetch
   408  a different URL</td></tr>
   409  <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RedirectTemp <var>URL-path</var> <var>URL</var></code></td></tr>
   410  <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
   411  <tr><th><a href="directive-dict.html#Override">Override:</a></th><td>FileInfo</td></tr>
   412  <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
   413  <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_alias</td></tr>
   414  </table>
   415      <p>This directive makes the client know that the Redirect is
   416      only temporary (status 302). Exactly equivalent to
   417      <code>Redirect temp</code>.</p>
   418  
   419  </div>
   420  <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
   421  <div class="directive-section"><h2><a name="ScriptAlias" id="ScriptAlias">ScriptAlias</a> <a name="scriptalias" id="scriptalias">Directive</a></h2>
   422  <table class="directive">
   423  <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Maps a URL to a filesystem location and designates the
   424  target as a CGI script</td></tr>
   425  <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>ScriptAlias <var>URL-path</var>
   426  <var>file-path</var>|<var>directory-path</var></code></td></tr>
   427  <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
   428  <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
   429  <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_alias</td></tr>
   430  </table>
   431      <p>The <code class="directive">ScriptAlias</code> directive has the same
   432      behavior as the <code class="directive"><a href="#alias">Alias</a></code>
   433      directive, except that in addition it marks the target directory
   434      as containing CGI scripts that will be processed by <code class="module"><a href="../mod/mod_cgi.html">mod_cgi</a></code>'s cgi-script handler. URLs with a case-sensitive
   435      (%-decoded) path beginning with <var>URL-path</var> will be mapped
   436      to scripts beginning with the second argument, which is a full
   437      pathname in the local filesystem.</p>
   438  
   439      <div class="example"><h3>Example:</h3><p><code>
   440        ScriptAlias /cgi-bin/ /web/cgi-bin/
   441      </code></p></div>
   442  
   443      <p>A request for <code>http://example.com/cgi-bin/foo</code> would cause the
   444      server to run the script <code>/web/cgi-bin/foo</code>.  This configuration
   445      is essentially equivalent to:</p>
   446      <div class="example"><p><code>
   447        Alias /cgi-bin/ /web/cgi-bin/<br />
   448        &lt;Location /cgi-bin &gt;<br />
   449        <span class="indent">
   450        SetHandler cgi-script<br />
   451        Options +ExecCGI<br />
   452        </span>
   453        &lt;/Location&gt;
   454      </code></p></div>
   455  
   456      <div class="warning">It is safer to avoid placing CGI scripts under the
   457      <code class="directive"><a href="../mod/core.html#documentroot">DocumentRoot</a></code> in order to
   458      avoid accidentally revealing their source code if the
   459      configuration is ever changed.  The
   460      <code class="directive">ScriptAlias</code> makes this easy by mapping a
   461      URL and designating CGI scripts at the same time.  If you do
   462      choose to place your CGI scripts in a directory already
   463      accessible from the web, do not use
   464      <code class="directive">ScriptAlias</code>.  Instead, use <code class="directive"><a href="../mod/core.html#directory">&lt;Directory&gt;</a></code>, <code class="directive"><a href="../mod/core.html#sethandler">SetHandler</a></code>, and <code class="directive"><a href="../mod/core.html#options">Options</a></code> as in:
   465      <div class="example"><p><code>
   466        &lt;Directory /usr/local/apache2/htdocs/cgi-bin &gt;<br />
   467        <span class="indent">
   468        SetHandler cgi-script<br />
   469        Options ExecCGI<br />
   470        </span>
   471        &lt;/Directory&gt;
   472      </code></p></div>
   473      This is necessary since multiple <var>URL-paths</var> can map
   474      to the same filesystem location, potentially bypassing the
   475      <code class="directive">ScriptAlias</code> and revealing the source code
   476      of the CGI scripts if they are not restricted by a
   477      <code class="directive"><a href="../mod/core.html#directory">Directory</a></code> section.</div>
   478  
   479  
   480  <h3>See also</h3>
   481  <ul>
   482  <li><a href="../howto/cgi.html">CGI Tutorial</a></li>
   483  </ul>
   484  </div>
   485  <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
   486  <div class="directive-section"><h2><a name="ScriptAliasMatch" id="ScriptAliasMatch">ScriptAliasMatch</a> <a name="scriptaliasmatch" id="scriptaliasmatch">Directive</a></h2>
   487  <table class="directive">
   488  <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Maps a URL to a filesystem location using a regular expression
   489  and designates the target as a CGI script</td></tr>
   490  <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>ScriptAliasMatch <var>regex</var>
   491  <var>file-path</var>|<var>directory-path</var></code></td></tr>
   492  <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
   493  <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
   494  <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_alias</td></tr>
   495  </table>
   496      <p>This directive is equivalent to <code class="directive"><a href="#scriptalias">ScriptAlias</a></code>, but makes use of
   497      <a class="glossarylink" href="../glossary.html#regex" title="see glossary">regular expressions</a>,
   498      instead of simple prefix matching. The
   499      supplied regular expression is matched against the URL-path,
   500      and if it matches, the server will substitute any parenthesized
   501      matches into the given string and use it as a filename. For
   502      example, to activate the standard <code>/cgi-bin</code>, one
   503      might use:</p>
   504  
   505      <div class="example"><p><code>
   506        ScriptAliasMatch ^/cgi-bin(.*) /usr/local/apache/cgi-bin$1
   507      </code></p></div>
   508  
   509      <p>As for AliasMatch, the full range of <a class="glossarylink" href="../glossary.html#rexex" title="see glossary">regular
   510      expression</a> power is available.
   511      For example, it is possible to construct an alias with case-insensitive
   512      matching of the URL-path:</p>
   513  
   514      <div class="example"><p><code>
   515        ScriptAliasMatch (?i)^/cgi-bin(.*) /usr/local/apache/cgi-bin$1
   516      </code></p></div>
   517  
   518      <p>The considerations related to the difference between
   519      <code class="directive"><a href="#alias">Alias</a></code> and
   520      <code class="directive"><a href="#aliasmatch">AliasMatch</a></code>
   521      also apply to the difference between
   522      <code class="directive"><a href="#scriptalias">ScriptAlias</a></code> and
   523      <code class="directive"><a href="#scriptaliasmatch">ScriptAliasMatch</a></code>.
   524      See <code class="directive"><a href="#aliasmatch">AliasMatch</a></code> for
   525      details.</p>
   526  
   527  
   528  </div>
   529  </div>
   530  <div class="bottomlang">
   531  <p><span>Available Languages: </span><a href="../en/mod/mod_alias.html" title="English">&nbsp;en&nbsp;</a> |
   532  <a href="../ja/mod/mod_alias.html" hreflang="ja" rel="alternate" title="Japanese">&nbsp;ja&nbsp;</a> |
   533  <a href="../ko/mod/mod_alias.html" hreflang="ko" rel="alternate" title="Korean">&nbsp;ko&nbsp;</a> |
   534  <a href="../tr/mod/mod_alias.html" hreflang="tr" rel="alternate" title="Türkçe">&nbsp;tr&nbsp;</a></p>
   535  </div><div class="top"><a href="#page-header"><img src="../images/up.gif" alt="top" /></a></div><div class="section"><h2><a id="comments_section" name="comments_section">Comments</a></h2><div class="warning"><strong>Notice:</strong><br />This is not a Q&amp;A section. Comments placed here should be pointed towards suggestions on improving the documentation or server, and may be removed again by our moderators if they are either implemented or considered invalid/off-topic. Questions on how to manage the Apache HTTP Server should be directed at either our IRC channel, #httpd, on Freenode, or sent to our <a href="http://httpd.apache.org/lists.html">mailing lists</a>.</div>
   536  <script type="text/javascript"><!--//--><![CDATA[//><!--
   537  var comments_shortname = 'httpd';
   538  var comments_identifier = 'http://httpd.apache.org/docs/2.2/mod/mod_alias.html';
   539  (function(w, d) {
   540      if (w.location.hostname.toLowerCase() == "httpd.apache.org") {
   541          d.write('<div id="comments_thread"><\/div>');
   542          var s = d.createElement('script');
   543          s.type = 'text/javascript';
   544          s.async = true;
   545          s.src = 'https://comments.apache.org/show_comments.lua?site=' + comments_shortname + '&page=' + comments_identifier;
   546          (d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0]).appendChild(s);
   547      }
   548      else { 
   549          d.write('<div id="comments_thread">Comments are disabled for this page at the moment.<\/div>');
   550      }
   551  })(window, document);
   552  //--><!]]></script></div><div id="footer">
   553  <p class="apache">Copyright 2017 The Apache Software Foundation.<br />Licensed under the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>.</p>
   554  <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="http://wiki.apache.org/httpd/FAQ">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p></div><script type="text/javascript"><!--//--><![CDATA[//><!--
   555  if (typeof(prettyPrint) !== 'undefined') {
   556      prettyPrint();
   557  }
   558  //--><!]]></script>
   559  </body></html>