github.com/krum110487/go-htaccess@v0.0.0-20240316004156-60641c8e7598/tests/data/apache_2_2_34/manual/mod/mod_vhost_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_vhost_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_vhost_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_vhost_alias.html">this link</a> to go to the current version of this document.</p></div><div id="preamble"><h1>Apache Module mod_vhost_alias</h1>
    30  <div class="toplang">
    31  <p><span>Available Languages: </span><a href="../en/mod/mod_vhost_alias.html" title="English">&nbsp;en&nbsp;</a> |
    32  <a href="../tr/mod/mod_vhost_alias.html" hreflang="tr" rel="alternate" title="Türkçe">&nbsp;tr&nbsp;</a></p>
    33  </div>
    34  <table class="module"><tr><th><a href="module-dict.html#Description">Description:</a></th><td>Provides for dynamically configured mass virtual
    35  hosting</td></tr>
    36  <tr><th><a href="module-dict.html#Status">Status:</a></th><td>Extension</td></tr>
    37  <tr><th><a href="module-dict.html#ModuleIdentifier">Module Identifier:</a></th><td>vhost_alias_module</td></tr>
    38  <tr><th><a href="module-dict.html#SourceFile">Source File:</a></th><td>mod_vhost_alias.c</td></tr></table>
    39  <h3>Summary</h3>
    40  
    41      <p>This module creates dynamically configured virtual hosts, by
    42      allowing the IP address and/or the <code>Host:</code> header of
    43      the HTTP request to be used as part of the pathname to
    44      determine what files to serve. This allows for easy use of a
    45      huge number of virtual hosts with similar configurations.</p>
    46      
    47      <div class="note"><h3>Note</h3>
    48        <p>If <code class="module"><a href="../mod/mod_alias.html">mod_alias</a></code> or <code class="module"><a href="../mod/mod_userdir.html">mod_userdir</a></code> are
    49        used for translating URIs to filenames, they will override the
    50        directives of <code class="module"><a href="../mod/mod_vhost_alias.html">mod_vhost_alias</a></code> described below. For
    51        example, the following configuration will map <code>
    52        /cgi-bin/script.pl</code> to <code>
    53        /usr/local/apache2/cgi-bin/script.pl</code> in all cases:</p>
    54  
    55        <div class="example"><p><code>
    56          ScriptAlias /cgi-bin/ /usr/local/apache2/cgi-bin/<br />
    57          VirtualScriptAlias /never/found/%0/cgi-bin/
    58        </code></p></div>
    59      </div>
    60  </div>
    61  <div id="quickview"><h3>Topics</h3>
    62  <ul id="topics">
    63  <li><img alt="" src="../images/down.gif" /> <a href="#interpol">Directory Name Interpolation</a></li>
    64  <li><img alt="" src="../images/down.gif" /> <a href="#examples">Examples</a></li>
    65  </ul><h3 class="directives">Directives</h3>
    66  <ul id="toc">
    67  <li><img alt="" src="../images/down.gif" /> <a href="#virtualdocumentroot">VirtualDocumentRoot</a></li>
    68  <li><img alt="" src="../images/down.gif" /> <a href="#virtualdocumentrootip">VirtualDocumentRootIP</a></li>
    69  <li><img alt="" src="../images/down.gif" /> <a href="#virtualscriptalias">VirtualScriptAlias</a></li>
    70  <li><img alt="" src="../images/down.gif" /> <a href="#virtualscriptaliasip">VirtualScriptAliasIP</a></li>
    71  </ul>
    72  <h3>See also</h3>
    73  <ul class="seealso">
    74  <li><code class="directive"><a href="../mod/core.html#usecanonicalname">UseCanonicalName</a></code></li>
    75  <li><a href="../vhosts/mass.html">Dynamically configured mass 
    76      virtual hosting</a></li>
    77  </ul><ul class="seealso"><li><a href="#comments_section">Comments</a></li></ul></div>
    78  <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
    79  <div class="section">
    80  <h2><a name="interpol" id="interpol">Directory Name Interpolation</a></h2>
    81      
    82  
    83      <p>All the directives in this module interpolate a string into
    84      a pathname. The interpolated string (henceforth called the
    85      "name") may be either the server name (see the <code class="directive"><a href="../mod/core.html#usecanonicalname">UseCanonicalName</a></code>
    86      directive for details on how this is determined) or the IP
    87      address of the virtual host on the server in dotted-quad
    88      format. The interpolation is controlled by specifiers inspired
    89      by <code>printf</code> which have a number of formats:</p>
    90  
    91  <table>
    92  
    93  <tr><td><code>%%</code></td>
    94  <td>insert a <code>%</code></td></tr>
    95  
    96  <tr><td><code>%p</code></td>
    97  <td>insert the port number of the virtual host</td></tr>
    98  
    99  <tr><td><code>%N.M</code></td>
   100  <td>insert (part of) the name</td></tr>
   101       
   102  </table>
   103  
   104      <p><code>N</code> and <code>M</code> are used to specify
   105      substrings of the name. <code>N</code> selects from the
   106      dot-separated components of the name, and <code>M</code>
   107      selects characters within whatever <code>N</code> has selected.
   108      <code>M</code> is optional and defaults to zero if it isn't
   109      present; the dot must be present if and only if <code>M</code>
   110      is present. The interpretation is as follows:</p>
   111  
   112      <table>
   113        
   114        <tr><td><code>0</code></td>
   115        <td>the whole name</td></tr>
   116  
   117        <tr><td><code>1</code></td>
   118        <td>the first part</td></tr>
   119  
   120        <tr><td><code>2</code></td>
   121        <td>the second part</td></tr>
   122  
   123        <tr><td><code>-1</code></td>
   124        <td>the last part</td></tr>
   125  
   126        <tr><td><code>-2</code></td>
   127        <td>the penultimate part</td></tr>
   128  
   129        <tr><td><code>2+</code></td>
   130        <td>the second and all subsequent parts</td></tr>
   131  
   132        <tr><td><code>-2+</code></td>
   133        <td>the penultimate and all preceding parts</td></tr>
   134  
   135        <tr><td><code>1+</code> and <code>-1+</code></td>
   136        <td>the same as <code>0</code></td></tr>
   137      </table>
   138  
   139      <p>If <code>N</code> or <code>M</code> is greater than the number
   140      of parts available a single underscore is interpolated. </p>
   141  
   142  </div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
   143  <div class="section">
   144  <h2><a name="examples" id="examples">Examples</a></h2>
   145      
   146  
   147      <p>For simple name-based virtual hosts you might use the
   148      following directives in your server configuration file:</p>
   149  
   150      <div class="example"><p><code>
   151        UseCanonicalName    Off<br />
   152        VirtualDocumentRoot /usr/local/apache/vhosts/%0
   153      </code></p></div>
   154  
   155      <p>A request for
   156      <code>http://www.example.com/directory/file.html</code> will be
   157      satisfied by the file
   158      <code>/usr/local/apache/vhosts/www.example.com/directory/file.html</code>.
   159      </p> 
   160  
   161      <p>For a very large number of virtual hosts it is a good idea
   162      to arrange the files to reduce the size of the
   163      <code>vhosts</code> directory. To do this you might use the
   164      following in your configuration file:</p>
   165  
   166      <div class="example"><p><code>
   167        UseCanonicalName    Off<br />
   168        VirtualDocumentRoot /usr/local/apache/vhosts/%3+/%2.1/%2.2/%2.3/%2
   169      </code></p></div>
   170  
   171      <p>A request for
   172      <code>http://www.domain.example.com/directory/file.html</code>
   173      will be satisfied by the file
   174      <code>/usr/local/apache/vhosts/example.com/d/o/m/domain/directory/file.html</code>.</p>
   175  
   176      <p>A more even spread of files can be achieved by hashing from the
   177      end of the name, for example: </p>
   178  
   179  <div class="example"><p><code>
   180      VirtualDocumentRoot /usr/local/apache/vhosts/%3+/%2.-1/%2.-2/%2.-3/%2
   181  </code></p></div>
   182  
   183      <p>The example request would come from
   184      <code>/usr/local/apache/vhosts/example.com/n/i/a/domain/directory/file.html</code>.</p>
   185  
   186      <p>Alternatively you might use: </p>
   187  
   188  <div class="example"><p><code>
   189      VirtualDocumentRoot /usr/local/apache/vhosts/%3+/%2.1/%2.2/%2.3/%2.4+
   190  </code></p></div>
   191  
   192      <p>The example request would come from
   193      <code>/usr/local/apache/vhosts/example.com/d/o/m/ain/directory/file.html</code>.</p>
   194  
   195      <p>For IP-based virtual hosting you might use the following in
   196      your configuration file:</p>
   197  
   198      <div class="example"><p><code>
   199        UseCanonicalName DNS<br />
   200        VirtualDocumentRootIP /usr/local/apache/vhosts/%1/%2/%3/%4/docs<br />
   201        VirtualScriptAliasIP  /usr/local/apache/vhosts/%1/%2/%3/%4/cgi-bin
   202      </code></p></div>
   203  
   204      <p>A request for
   205      <code>http://www.domain.example.com/directory/file.html</code>
   206      would be satisfied by the file
   207      <code>/usr/local/apache/vhosts/10/20/30/40/docs/directory/file.html</code>
   208      if the IP address of <code>www.domain.example.com</code> were
   209      10.20.30.40. A request for
   210      <code>http://www.domain.example.com/cgi-bin/script.pl</code> would
   211      be satisfied by executing the program
   212      <code>/usr/local/apache/vhosts/10/20/30/40/cgi-bin/script.pl</code>.</p>
   213  
   214      <p>If you want to include the <code>.</code> character in a
   215      <code>VirtualDocumentRoot</code> directive, but it clashes with
   216      a <code>%</code> directive, you can work around the problem in
   217      the following way:</p>
   218  
   219  <div class="example"><p><code>
   220      VirtualDocumentRoot /usr/local/apache/vhosts/%2.0.%3.0
   221  </code></p></div>
   222  
   223      <p>A request for
   224      <code>http://www.domain.example.com/directory/file.html</code>
   225      will be satisfied by the file
   226      <code>/usr/local/apache/vhosts/domain.example/directory/file.html</code>.</p>
   227       
   228      <p>The <code class="directive"><a href="../mod/mod_log_config.html#logformat">LogFormat</a></code>
   229      directives <code>%V</code> and <code>%A</code> are useful
   230      in conjunction with this module.</p>
   231  </div>
   232  <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
   233  <div class="directive-section"><h2><a name="VirtualDocumentRoot" id="VirtualDocumentRoot">VirtualDocumentRoot</a> <a name="virtualdocumentroot" id="virtualdocumentroot">Directive</a></h2>
   234  <table class="directive">
   235  <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Dynamically configure the location of the document root
   236  for a given virtual host</td></tr>
   237  <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>VirtualDocumentRoot <em>interpolated-directory</em>|none</code></td></tr>
   238  <tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>VirtualDocumentRoot none</code></td></tr>
   239  <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
   240  <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
   241  <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_vhost_alias</td></tr>
   242  </table>
   243  
   244      <p>The <code class="directive">VirtualDocumentRoot</code> directive allows you to
   245      determine where Apache will find your documents based on the
   246      value of the server name. The result of expanding
   247      <em>interpolated-directory</em> is used as the root of the
   248      document tree in a similar manner to the <code class="directive"><a href="../mod/core.html#documentroot">DocumentRoot</a></code> directive's argument. 
   249      If <em>interpolated-directory</em> is <code>none</code> then
   250      <code class="directive">VirtualDocumentRoot</code> is turned off. This directive 
   251      cannot be used in the same context as <code class="directive"><a href="#virtualdocumentrootip">VirtualDocumentRootIP</a></code>.</p>
   252  
   253  
   254  </div>
   255  <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
   256  <div class="directive-section"><h2><a name="VirtualDocumentRootIP" id="VirtualDocumentRootIP">VirtualDocumentRootIP</a> <a name="virtualdocumentrootip" id="virtualdocumentrootip">Directive</a></h2>
   257  <table class="directive">
   258  <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Dynamically configure the location of the document root
   259  for a given virtual host</td></tr>
   260  <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>VirtualDocumentRootIP <em>interpolated-directory</em>|none</code></td></tr>
   261  <tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>VirtualDocumentRootIP none</code></td></tr>
   262  <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
   263  <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
   264  <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_vhost_alias</td></tr>
   265  </table>
   266  
   267  <p>The <code class="directive">VirtualDocumentRootIP</code> directive is like the
   268      <code class="directive"><a href="#virtualdocumentroot">VirtualDocumentRoot</a></code>
   269      directive, except that it uses the IP address of the server end
   270      of the connection for directory interpolation instead of the server
   271      name.</p>
   272  
   273  </div>
   274  <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
   275  <div class="directive-section"><h2><a name="VirtualScriptAlias" id="VirtualScriptAlias">VirtualScriptAlias</a> <a name="virtualscriptalias" id="virtualscriptalias">Directive</a></h2>
   276  <table class="directive">
   277  <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Dynamically configure the location of the CGI directory for
   278  a given virtual host</td></tr>
   279  <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>VirtualScriptAlias <em>interpolated-directory</em>|none</code></td></tr>
   280  <tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>VirtualScriptAlias none</code></td></tr>
   281  <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
   282  <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
   283  <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_vhost_alias</td></tr>
   284  </table>
   285  
   286      <p>The <code class="directive">VirtualScriptAlias</code> directive allows you to
   287      determine where Apache will find CGI scripts in a similar
   288      manner to <code class="directive"><a href="#virtualdocumentroot">VirtualDocumentRoot</a></code> does for other documents. It matches
   289      requests for URIs starting <code>/cgi-bin/</code>, much like <code class="directive"><a href="../mod/mod_alias.html#scriptalias">ScriptAlias</a></code>
   290      <code>/cgi-bin/</code> would.</p>
   291  
   292  
   293  </div>
   294  <div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div>
   295  <div class="directive-section"><h2><a name="VirtualScriptAliasIP" id="VirtualScriptAliasIP">VirtualScriptAliasIP</a> <a name="virtualscriptaliasip" id="virtualscriptaliasip">Directive</a></h2>
   296  <table class="directive">
   297  <tr><th><a href="directive-dict.html#Description">Description:</a></th><td>Dynamically configure the location of the cgi directory for
   298  a given virtual host</td></tr>
   299  <tr><th><a href="directive-dict.html#Syntax">Syntax:</a></th><td><code>VirtualScriptAliasIP <em>interpolated-directory</em>|none</code></td></tr>
   300  <tr><th><a href="directive-dict.html#Default">Default:</a></th><td><code>VirtualScriptAliasIP none</code></td></tr>
   301  <tr><th><a href="directive-dict.html#Context">Context:</a></th><td>server config, virtual host</td></tr>
   302  <tr><th><a href="directive-dict.html#Status">Status:</a></th><td>Extension</td></tr>
   303  <tr><th><a href="directive-dict.html#Module">Module:</a></th><td>mod_vhost_alias</td></tr>
   304  </table>
   305  
   306      <p>The <code class="directive">VirtualScriptAliasIP</code> directive is like the
   307      <code class="directive"><a href="#virtualscriptalias">VirtualScriptAlias</a></code>
   308      directive, except that it uses the IP address of the server end
   309      of the connection for directory interpolation instead of the server
   310      name.</p>
   311  
   312      
   313  </div>
   314  </div>
   315  <div class="bottomlang">
   316  <p><span>Available Languages: </span><a href="../en/mod/mod_vhost_alias.html" title="English">&nbsp;en&nbsp;</a> |
   317  <a href="../tr/mod/mod_vhost_alias.html" hreflang="tr" rel="alternate" title="Türkçe">&nbsp;tr&nbsp;</a></p>
   318  </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>
   319  <script type="text/javascript"><!--//--><![CDATA[//><!--
   320  var comments_shortname = 'httpd';
   321  var comments_identifier = 'http://httpd.apache.org/docs/2.2/mod/mod_vhost_alias.html';
   322  (function(w, d) {
   323      if (w.location.hostname.toLowerCase() == "httpd.apache.org") {
   324          d.write('<div id="comments_thread"><\/div>');
   325          var s = d.createElement('script');
   326          s.type = 'text/javascript';
   327          s.async = true;
   328          s.src = 'https://comments.apache.org/show_comments.lua?site=' + comments_shortname + '&page=' + comments_identifier;
   329          (d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0]).appendChild(s);
   330      }
   331      else { 
   332          d.write('<div id="comments_thread">Comments are disabled for this page at the moment.<\/div>');
   333      }
   334  })(window, document);
   335  //--><!]]></script></div><div id="footer">
   336  <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>
   337  <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[//><!--
   338  if (typeof(prettyPrint) !== 'undefined') {
   339      prettyPrint();
   340  }
   341  //--><!]]></script>
   342  </body></html>