home *** CD-ROM | disk | FTP | other *** search
/ Cricao de Sites - 650 Layouts Prontos / WebMasters.iso / Servidores / apache_2.2.8-win32-x86-no_ssl.msi / Data1.cab / _EBBFC9E7A44AFB6077B9912D252A99EB < prev    next >
Extensible Markup Language  |  2007-09-01  |  26KB  |  439 lines

  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.         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  5.               This file is generated from xml source: DO NOT EDIT
  6.         XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
  7.       -->
  8. <title>mod_alias - Apache HTTP Server</title>
  9. <link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
  10. <link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
  11. <link href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" />
  12. <link href="../images/favicon.ico" rel="shortcut icon" /></head>
  13. <body>
  14. <div id="page-header">
  15. <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="../faq/">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p>
  16. <p class="apache">Apache HTTP Server Version 2.2</p>
  17. <img alt="" src="../images/feather.gif" /></div>
  18. <div class="up"><a href="./"><img title="<-" alt="<-" src="../images/left.gif" /></a></div>
  19. <div id="path">
  20. <a href="http://www.apache.org/">Apache</a> > <a href="http://httpd.apache.org/">HTTP Server</a> > <a href="http://httpd.apache.org/docs/">Documentation</a> > <a href="../">Version 2.2</a> > <a href="./">Modules</a></div>
  21. <div id="page-content">
  22. <div id="preamble"><h1>Apache Module mod_alias</h1>
  23. <div class="toplang">
  24. <p><span>Available Languages: </span><a href="../en/mod/mod_alias.html" title="English"> en </a> |
  25. <a href="../ja/mod/mod_alias.html" hreflang="ja" rel="alternate" title="Japanese"> ja </a> |
  26. <a href="../ko/mod/mod_alias.html" hreflang="ko" rel="alternate" title="Korean"> ko </a></p>
  27. </div>
  28. <table class="module"><tr><th><a href="module-dict.html#Description">Description:</a></th><td>Provides for mapping different parts of the host
  29.     filesystem in the document tree and for URL redirection</td></tr>
  30. <tr><th><a href="module-dict.html#Status">Status:</a></th><td>Base</td></tr>
  31. <tr><th><a href="module-dict.html#ModuleIdentifier">ModuleáIdentifier:</a></th><td>alias_module</td></tr>
  32. <tr><th><a href="module-dict.html#SourceFile">SourceáFile:</a></th><td>mod_alias.c</td></tr></table>
  33. <h3>Summary</h3>
  34.  
  35.     <p>The directives contained in this module allow for manipulation
  36.     and control of URLs as requests arrive at the server. The
  37.     <code class="directive"><a href="#alias">Alias</a></code> and <code class="directive"><a href="#scriptalias">ScriptAlias</a></code> directives are used to
  38.     map between URLs and filesystem paths.  This allows for content
  39.     which is not directly under the <code class="directive"><a href="../mod/core.html#documentroot">DocumentRoot</a></code> served as part of the web
  40.     document tree. The <code class="directive"><a href="#scriptalias">ScriptAlias</a></code> directive has the
  41.     additional effect of marking the target directory as containing
  42.     only CGI scripts.</p>
  43.  
  44.     <p>The <code class="directive"><a href="#redirect">Redirect</a></code>
  45.     directives are used to instruct clients to make a new request with
  46.     a different URL. They are often used when a resource has moved to
  47.     a new location.</p>
  48.  
  49.     <p><code class="module"><a href="../mod/mod_alias.html">mod_alias</a></code> is designed to handle simple URL
  50.     manipulation tasks.  For more complicated tasks such as
  51.     manipulating the query string, use the tools provided by
  52.     <code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code>.</p>
  53.  
  54. </div>
  55. <div id="quickview"><h3 class="directives">Directives</h3>
  56. <ul id="toc">
  57. <li><img alt="" src="../images/down.gif" /> <a href="#alias">Alias</a></li>
  58. <li><img alt="" src="../images/down.gif" /> <a href="#aliasmatch">AliasMatch</a></li>
  59. <li><img alt="" src="../images/down.gif" /> <a href="#redirect">Redirect</a></li>
  60. <li><img alt="" src="../images/down.gif" /> <a href="#redirectmatch">RedirectMatch</a></li>
  61. <li><img alt="" src="../images/down.gif" /> <a href="#redirectpermanent">RedirectPermanent</a></li>
  62. <li><img alt="" src="../images/down.gif" /> <a href="#redirecttemp">RedirectTemp</a></li>
  63. <li><img alt="" src="../images/down.gif" /> <a href="#scriptalias">ScriptAlias</a></li>
  64. <li><img alt="" src="../images/down.gif" /> <a href="#scriptaliasmatch">ScriptAliasMatch</a></li>
  65. </ul>
  66. <h3>Topics</h3>
  67. <ul id="topics">
  68. <li><img alt="" src="../images/down.gif" /> <a href="#order">Order of Processing</a></li>
  69. </ul><h3>See also</h3>
  70. <ul class="seealso">
  71. <li><code class="module"><a href="../mod/mod_rewrite.html">mod_rewrite</a></code></li>
  72. <li><a href="../urlmapping.html">Mapping URLs to the filesystem</a></li>
  73. </ul></div>
  74. <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
  75. <div class="section">
  76. <h2><a name="order" id="order">Order of Processing</a></h2>
  77.  
  78. <p>Aliases and Redirects occuring in different contexts are processed
  79. like other directives according to standard <a href="../sections.html#mergin">merging rules</a>.  But when multiple
  80. Aliases or Redirects occur in the same context (for example, in the
  81. same <code class="directive"><a href="../mod/core.html#virtualhost"><VirtualHost></a></code>
  82. section) they are processed in a particular order.</p>
  83.  
  84. <p>First, all Redirects are processed before Aliases are processed,
  85. 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
  86. applied.  Second, the Aliases and Redirects are processed in the order
  87. they appear in the configuration files, with the first match taking
  88. precedence.</p>
  89.  
  90. <p>For this reason, when two or more of these directives apply to the
  91. same sub-path, you must list the most specific path first in order for
  92. all the directives to have an effect.  For example, the following
  93. configuration will work as expected:</p>
  94.  
  95. <div class="example"><p><code>
  96. Alias /foo/bar /baz<br />
  97. Alias /foo /gaq
  98. </code></p></div>
  99.  
  100. <p>But if the above two directives were reversed in order, the
  101. <code>/foo</code> <code class="directive"><a href="#alias">Alias</a></code>
  102. would always match before the <code>/foo/bar</code> <code class="directive"><a href="#alias">Alias</a></code>, so the latter directive would be
  103. ignored.</p>
  104.  
  105. </div>
  106. <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
  107. <div class="directive-section"><h2><a name="Alias" id="Alias">Alias</a> <a name="alias" id="alias">Directive</a></h2>
  108. <table class="directive">
  109. <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Maps URLs to filesystem locations</td></tr>
  110. <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>Alias <var>URL-path</var>
  111. <var>file-path</var>|<var>directory-path</var></code></td></tr>
  112. <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
  113. <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
  114. <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_alias</td></tr>
  115. </table>
  116.  
  117.     <p>The <code class="directive">Alias</code> directive allows documents to
  118.     be stored in the local filesystem other than under the 
  119.     <code class="directive"><a href="../mod/core.html#documentroot">DocumentRoot</a></code>. URLs with a
  120.     (%-decoded) path beginning with <var>url-path</var> will be mapped
  121.     to local files beginning with <var>directory-path</var>.  The 
  122.     <var>url-path</var> is case-sensitive, even on case-insensitive 
  123.     file systems.</p>
  124.  
  125.     <div class="example"><h3>Example:</h3><p><code>
  126.       Alias /image /ftp/pub/image
  127.     </code></p></div>
  128.  
  129.     <p>A request for http://myserver/image/foo.gif would cause the
  130.     server to return the file /ftp/pub/image/foo.gif.  Only complete
  131.     path segments are matched, so the above alias would not match a
  132.     request for http://myserver/imagefoo.gif.  For more complex
  133.     matching using regular expressions, see the <code class="directive"><a href="#aliasmatch">AliasMatch</a></code> directive.</p>
  134.  
  135.     <p>Note that if you include a trailing / on the
  136.     <var>url-path</var> then the server will require a trailing / in
  137.     order to expand the alias. That is, if you use <code>Alias
  138.     /icons/ /usr/local/apache/icons/</code> then the url
  139.     <code>/icons</code> will not be aliased.</p>
  140.  
  141.     <p>Note that you may need to specify additional <code class="directive"><a href="../mod/core.html#directory"><Directory></a></code> sections which
  142.     cover the <em>destination</em> of aliases.  Aliasing occurs before
  143.     <code class="directive"><a href="../mod/core.html#directory"><Directory></a></code> sections
  144.     are checked, so only the destination of aliases are affected.
  145.     (Note however <code class="directive"><a href="../mod/core.html#location"><Location></a></code>
  146.     sections are run through once before aliases are performed, so
  147.     they will apply.)</p>
  148.  
  149.     <p>In particular, if you are creating an <code>Alias</code> to a
  150.     directory outside of your <code class="directive"><a href="../mod/core.html#documentroot">DocumentRoot</a></code>, you may need to explicitly
  151.     permit access to the target directory.</p>
  152.  
  153.     <div class="example"><h3>Example:</h3><p><code>
  154.         Alias /image /ftp/pub/image<br />
  155.         <Directory /ftp/pub/image><br />
  156.         <span class="indent">
  157.             Order allow,deny<br />
  158.             Allow from all<br />
  159.         </span>
  160.         </Directory>
  161.     </code></p></div>
  162.  
  163.  
  164. </div>
  165. <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
  166. <div class="directive-section"><h2><a name="AliasMatch" id="AliasMatch">AliasMatch</a> <a name="aliasmatch" id="aliasmatch">Directive</a></h2>
  167. <table class="directive">
  168. <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Maps URLs to filesystem locations using regular 
  169. expressions</td></tr>
  170. <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>AliasMatch <var>regex</var>
  171. <var>file-path</var>|<var>directory-path</var></code></td></tr>
  172. <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
  173. <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
  174. <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_alias</td></tr>
  175. </table>
  176.     <p>This directive is equivalent to <code class="directive"><a href="#alias">Alias</a></code>, but makes use of 
  177.     <a class="glossarylink" href="../glossary.html#regex" title="see glossary">regular expressions</a>, 
  178.     instead of simple prefix matching. The
  179.     supplied regular expression is matched against the URL-path, and
  180.     if it matches, the server will substitute any parenthesized
  181.     matches into the given string and use it as a filename. For
  182.     example, to activate the <code>/icons</code> directory, one might
  183.     use:</p>
  184.  
  185.     <div class="example"><p><code>
  186.       AliasMatch ^/icons(.*) /usr/local/apache/icons$1
  187.     </code></p></div>
  188.  
  189.     <p>It is also possible to construct an alias with case-insensitive
  190.     matching of the url-path:</p>
  191.  
  192.     <div class="example"><p><code>
  193.       AliasMatch (?i)^/image(.*) /ftp/pub/image$1
  194.     </code></p></div>
  195.  
  196.  
  197. </div>
  198. <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
  199. <div class="directive-section"><h2><a name="Redirect" id="Redirect">Redirect</a> <a name="redirect" id="redirect">Directive</a></h2>
  200. <table class="directive">
  201. <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Sends an external redirect asking the client to fetch
  202. a different URL</td></tr>
  203. <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>Redirect [<var>status</var>] <var>URL-path</var>
  204. <var>URL</var></code></td></tr>
  205. <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
  206. <tr><th><a href="directive-dict.html#Override">Override:</a></th><td>FileInfo</td></tr>
  207. <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
  208. <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_alias</td></tr>
  209. </table>
  210.     <p>The Redirect directive maps an old URL into a new one by asking
  211.     the client to refetch the resource at the new location.</p>
  212.  
  213.     <p>The old <em>URL-path</em> is a case-sensitive (%-decoded) path
  214.     beginning with a slash.  A relative path is not allowed.  The new
  215.     <em>URL</em> should be an absolute URL beginning with a scheme and
  216.     hostname, but a URL-path beginning with a slash may also be used,
  217.     in which case the scheme and hostname of the current server will
  218.     be added.</p>
  219.  
  220.     <p>Then any request beginning with <em>URL-Path</em> will return a
  221.     redirect request to the client at the location of the target
  222.     <em>URL</em>.  Additional path information beyond the matched
  223.     <em>URL-Path</em> will be appended to the target URL.</p>
  224.  
  225.     <div class="example"><h3>Example:</h3><p><code>
  226.       Redirect /service http://foo2.example.com/service
  227.     </code></p></div>
  228.  
  229.     <p>If the client requests http://example.com/service/foo.txt, it
  230.     will be told to access http://foo2.example.com/service/foo.txt
  231.     instead.  Only complete path segments are matched, so the above
  232.     example would not match a request for
  233.     http://example.com/servicefoo.txt.  For more complex matching
  234.     using regular expressions, see the <code class="directive"><a href="#redirectmatch">RedirectMatch</a></code> directive.</p>
  235.  
  236.  
  237. <div class="note"><h3>Note</h3> <p>Redirect directives take precedence over
  238. Alias and ScriptAlias directives, irrespective of their ordering in
  239. the configuration file.</p></div>
  240.  
  241.     <p>If no <var>status</var> argument is given, the redirect will
  242.     be "temporary" (HTTP status 302). This indicates to the client
  243.     that the resource has moved temporarily. The <var>status</var>
  244.     argument can be used to return other HTTP status codes:</p>
  245.  
  246.     <dl>
  247.       <dt>permanent</dt>
  248.  
  249.       <dd>Returns a permanent redirect status (301) indicating that
  250.       the resource has moved permanently.</dd>
  251.  
  252.       <dt>temp</dt>
  253.  
  254.       <dd>Returns a temporary redirect status (302). This is the
  255.       default.</dd>
  256.  
  257.       <dt>seeother</dt>
  258.  
  259.       <dd>Returns a "See Other" status (303) indicating that the
  260.       resource has been replaced.</dd>
  261.  
  262.       <dt>gone</dt>
  263.  
  264.       <dd>Returns a "Gone" status (410) indicating that the
  265.       resource has been permanently removed. When this status is
  266.       used the <var>URL</var> argument should be omitted.</dd>
  267.     </dl>
  268.  
  269.     <p>Other status codes can be returned by giving the numeric
  270.     status code as the value of <var>status</var>. If the status is
  271.     between 300 and 399, the <var>URL</var> argument must be present,
  272.     otherwise it must be omitted. Note that the status must be
  273.     known to the Apache code (see the function
  274.     <code>send_error_response</code> in http_protocol.c).</p>
  275.  
  276.     <div class="example"><h3>Example:</h3><p><code>
  277.       Redirect permanent /one http://example.com/two<br />
  278.       Redirect 303 /three http://example.com/other
  279.     </code></p></div>
  280.  
  281.  
  282. </div>
  283. <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
  284. <div class="directive-section"><h2><a name="RedirectMatch" id="RedirectMatch">RedirectMatch</a> <a name="redirectmatch" id="redirectmatch">Directive</a></h2>
  285. <table class="directive">
  286. <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Sends an external redirect based on a regular expression match 
  287. of the current URL</td></tr>
  288. <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RedirectMatch [<var>status</var>] <var>regex</var>
  289. <var>URL</var></code></td></tr>
  290. <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
  291. <tr><th><a href="directive-dict.html#Override">Override:</a></th><td>FileInfo</td></tr>
  292. <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
  293. <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_alias</td></tr>
  294. </table>
  295.     <p>This directive is equivalent to <code class="directive"><a href="#redirect">Redirect</a></code>, but makes use of 
  296.     <a class="glossarylink" href="../glossary.html#regex" title="see glossary">regular expressions</a>, 
  297.     instead of simple prefix matching. The
  298.     supplied regular expression is matched against the URL-path, and
  299.     if it matches, the server will substitute any parenthesized
  300.     matches into the given string and use it as a filename. For
  301.     example, to redirect all GIF files to like-named JPEG files on
  302.     another server, one might use:</p>
  303.  
  304.     <div class="example"><p><code>
  305.       RedirectMatch (.*)\.gif$ http://www.anotherserver.com$1.jpg
  306.     </code></p></div>
  307.  
  308. </div>
  309. <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
  310. <div class="directive-section"><h2><a name="RedirectPermanent" id="RedirectPermanent">RedirectPermanent</a> <a name="redirectpermanent" id="redirectpermanent">Directive</a></h2>
  311. <table class="directive">
  312. <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Sends an external permanent redirect asking the client to fetch
  313. a different URL</td></tr>
  314. <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RedirectPermanent <var>URL-path</var> <var>URL</var></code></td></tr>
  315. <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
  316. <tr><th><a href="directive-dict.html#Override">Override:</a></th><td>FileInfo</td></tr>
  317. <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
  318. <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_alias</td></tr>
  319. </table>
  320.     <p>This directive makes the client know that the Redirect is
  321.     permanent (status 301). Exactly equivalent to <code>Redirect
  322.     permanent</code>.</p>
  323.  
  324. </div>
  325. <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
  326. <div class="directive-section"><h2><a name="RedirectTemp" id="RedirectTemp">RedirectTemp</a> <a name="redirecttemp" id="redirecttemp">Directive</a></h2>
  327. <table class="directive">
  328. <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Sends an external temporary redirect asking the client to fetch
  329. a different URL</td></tr>
  330. <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>RedirectTemp <var>URL-path</var> <var>URL</var></code></td></tr>
  331. <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host, directory, .htaccess</td></tr>
  332. <tr><th><a href="directive-dict.html#Override">Override:</a></th><td>FileInfo</td></tr>
  333. <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
  334. <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_alias</td></tr>
  335. </table>
  336.     <p>This directive makes the client know that the Redirect is
  337.     only temporary (status 302). Exactly equivalent to
  338.     <code>Redirect temp</code>.</p>
  339.  
  340. </div>
  341. <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
  342. <div class="directive-section"><h2><a name="ScriptAlias" id="ScriptAlias">ScriptAlias</a> <a name="scriptalias" id="scriptalias">Directive</a></h2>
  343. <table class="directive">
  344. <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Maps a URL to a filesystem location and designates the
  345. target as a CGI script</td></tr>
  346. <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>ScriptAlias <var>URL-path</var>
  347. <var>file-path</var>|<var>directory-path</var></code></td></tr>
  348. <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
  349. <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
  350. <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_alias</td></tr>
  351. </table>
  352.     <p>The <code class="directive">ScriptAlias</code> directive has the same
  353.     behavior as the <code class="directive"><a href="#alias">Alias</a></code>
  354.     directive, except that in addition it marks the target directory
  355.     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
  356.     (%-decoded) path beginning with <var>URL-path</var> will be mapped
  357.     to scripts beginning with the second argument, which is a full
  358.     pathname in the local filesystem.</p>
  359.  
  360.     <div class="example"><h3>Example:</h3><p><code>
  361.       ScriptAlias /cgi-bin/ /web/cgi-bin/
  362.     </code></p></div>
  363.  
  364.     <p>A request for <code>http://myserver/cgi-bin/foo</code> would cause the
  365.     server to run the script <code>/web/cgi-bin/foo</code>.  This configuration
  366.     is essentially equivalent to:</p>
  367.     <div class="example"><p><code>
  368.       Alias /cgi-bin/ /web/cgi-bin/<br />
  369.       <Location /cgi-bin ><br />
  370.       <span class="indent">
  371.       SetHandler cgi-script<br />
  372.       Options +ExecCGI<br />
  373.       </span>
  374.       </Location>
  375.     </code></p></div>
  376.  
  377.     <div class="warning">It is safer to avoid placing CGI scripts under the
  378.     <code class="directive"><a href="../mod/core.html#documentroot">DocumentRoot</a></code> in order to
  379.     avoid accidentally revealing their source code if the
  380.     configuration is ever changed.  The
  381.     <code class="directive">ScriptAlias</code> makes this easy by mapping a
  382.     URL and designating CGI scripts at the same time.  If you do
  383.     choose to place your CGI scripts in a directory already
  384.     accessible from the web, do not use
  385.     <code class="directive">ScriptAlias</code>.  Instead, use <code class="directive"><a href="../mod/core.html#directory"><Directory></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:
  386.     <div class="example"><p><code>
  387.       <Directory /usr/local/apache2/htdocs/cgi-bin ><br />
  388.       <span class="indent">
  389.       SetHandler cgi-script<br />
  390.       Options ExecCGI<br />
  391.       </span>
  392.       </Directory>
  393.     </code></p></div>
  394.     This is necessary since multiple <var>URL-paths</var> can map
  395.     to the same filesystem location, potentially bypassing the
  396.     <code class="directive">ScriptAlias</code> and revealing the source code
  397.     of the CGI scripts if they are not restricted by a 
  398.     <code class="directive"><a href="../mod/core.html#directory">Directory</a></code> section.</div>
  399.  
  400.  
  401. <h3>See also</h3>
  402. <ul>
  403. <li><a href="../howto/cgi.html">CGI Tutorial</a></li>
  404. </ul>
  405. </div>
  406. <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
  407. <div class="directive-section"><h2><a name="ScriptAliasMatch" id="ScriptAliasMatch">ScriptAliasMatch</a> <a name="scriptaliasmatch" id="scriptaliasmatch">Directive</a></h2>
  408. <table class="directive">
  409. <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Maps a URL to a filesystem location using a regular expression
  410. and designates the target as a CGI script</td></tr>
  411. <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>ScriptAliasMatch <var>regex</var>
  412. <var>file-path</var>|<var>directory-path</var></code></td></tr>
  413. <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
  414. <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Base</td></tr>
  415. <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_alias</td></tr>
  416. </table>
  417.     <p>This directive is equivalent to <code class="directive"><a href="#scriptalias">ScriptAlias</a></code>, but makes use of 
  418.     <a class="glossarylink" href="../glossary.html#regex" title="see glossary">regular expressions</a>, 
  419.     instead of simple prefix matching. The
  420.     supplied regular expression is matched against the URL-path,
  421.     and if it matches, the server will substitute any parenthesized
  422.     matches into the given string and use it as a filename. For
  423.     example, to activate the standard <code>/cgi-bin</code>, one
  424.     might use:</p>
  425.  
  426.     <div class="example"><p><code>
  427.       ScriptAliasMatch ^/cgi-bin(.*) /usr/local/apache/cgi-bin$1
  428.     </code></p></div>
  429.  
  430. </div>
  431. </div>
  432. <div class="bottomlang">
  433. <p><span>Available Languages: </span><a href="../en/mod/mod_alias.html" title="English"> en </a> |
  434. <a href="../ja/mod/mod_alias.html" hreflang="ja" rel="alternate" title="Japanese"> ja </a> |
  435. <a href="../ko/mod/mod_alias.html" hreflang="ko" rel="alternate" title="Korean"> ko </a></p>
  436. </div><div id="footer">
  437. <p class="apache">Copyright 2007 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>
  438. <p class="menu"><a href="../mod/">Modules</a> | <a href="../mod/directives.html">Directives</a> | <a href="../faq/">FAQ</a> | <a href="../glossary.html">Glossary</a> | <a href="../sitemap.html">Sitemap</a></p></div>
  439. </body></html>