details.html.en revision d229f940abfb2490dee17979e9a5ff31b7012eb5
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><!--
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess This file is generated from xml source: DO NOT EDIT
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
5a58787efeb02a1c3f06569d019ad81fd2efa06end<title>An In-Depth Discussion of Virtual Host Matching - Apache HTTP Server</title>
5a58787efeb02a1c3f06569d019ad81fd2efa06end<link href="/style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
5a58787efeb02a1c3f06569d019ad81fd2efa06end<link href="/style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
5a58787efeb02a1c3f06569d019ad81fd2efa06end<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" />
5a58787efeb02a1c3f06569d019ad81fd2efa06end<script src="/style/scripts/prettify.js" type="text/javascript">
5a58787efeb02a1c3f06569d019ad81fd2efa06end<link href="/images/favicon.ico" rel="shortcut icon" /></head>
5a58787efeb02a1c3f06569d019ad81fd2efa06end<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>
3b3b7fc78d1f5bfc2769903375050048ff41ff26nd<div class="up"><a href="./"><img title="<-" alt="<-" src="/images/left.gif" /></a></div>
ad74a0524a06bfe11b7de9e3b4ce7233ab3bd3f7nd<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.5</a> > <a href="./">Virtual Hosts</a></div><div id="page-content"><div id="preamble"><h1>An In-Depth Discussion of Virtual Host Matching</h1>
3b3b7fc78d1f5bfc2769903375050048ff41ff26nd<p><span>Available Languages: </span><a href="/en/vhosts/details.html" title="English"> en </a> |
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess<a href="/fr/vhosts/details.html" hreflang="fr" rel="alternate" title="Fran�ais"> fr </a> |
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess<a href="/ko/vhosts/details.html" hreflang="ko" rel="alternate" title="Korean"> ko </a> |
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess<a href="/tr/vhosts/details.html" hreflang="tr" rel="alternate" title="T�rk�e"> tr </a></p>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <p>This document attempts to explain
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess exactly what Apache HTTP Server does when deciding what virtual host to
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess serve a request from.</p>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <p>Most users should read about <a href="name-based.html#namevip">
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess Name-based vs. IP-based Virtual Hosts</a> to decide which type they
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess want to use, then read more about <a href="name-based.html">name-based</a>
5a58787efeb02a1c3f06569d019ad81fd2efa06end or <a href="ip-based.html">IP-based</a> virtualhosts, and then see
5a58787efeb02a1c3f06569d019ad81fd2efa06end <p>If you want to understand all the details, then you can
5a58787efeb02a1c3f06569d019ad81fd2efa06end come back to this page.</p>
5a58787efeb02a1c3f06569d019ad81fd2efa06end<div id="quickview"><ul id="toc"><li><img alt="" src="/images/down.gif" /> <a href="#configparsing">Configuration File</a></li>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess<li><img alt="" src="/images/down.gif" /> <a href="#hostmatching">Virtual Host Matching</a></li>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess<li><img alt="" src="/images/down.gif" /> <a href="#tips">Tips</a></li>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess</ul><h3>See also</h3><ul class="seealso"><li><a href="ip-based.html">IP-based Virtual Host Support</a></li><li><a href="name-based.html">Name-based Virtual Hosts Support</a></li><li><a href="examples.html">Virtual Host examples for common setups</a></li><li><a href="mass.html">Dynamically configured mass virtual hosting</a></li></ul></div>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess<h2><a name="configparsing" id="configparsing">Configuration File</a></h2>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <p>There is a <em>main server</em> which consists of all the
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess definitions appearing outside of
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <p>There are virtual
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <code class="directive"><a href="/mod/core.html#virtualhost"><VirtualHost></a></code>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess sections.</p>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <p>Each <code>VirtualHost</code> directive includes one
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess or more addresses and optional ports.</p>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <p>Hostnames can be used in place of IP addresses in a virtual
378b5789dab3a2cd1b4b96ac8e6636ee61024c82trawick host definition, but they are resolved at startup and if any name
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess resolutions fail, those virtual host definitions are ignored.
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess This is, therefore, not recommended.</p>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <p>The address can be specified as
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess other vhost has the explicit address on which the request was
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess received. </p>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <p>The address appearing in the <code>VirtualHost</code>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess directive can have an optional port. If the port is unspecified,
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess it is treated as a wildcard port, which can also be indicated
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess The wildcard port matches any port.</p>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <p>(Port numbers specified in the <code>VirtualHost</code> directive do
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess not influence what port numbers Apache will listen on, they only control
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess which <code>VirtualHost</code> will be selected to handle a request.
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess Use the <code class="directive"><a href="/mod/mpm_common.html#listen">Listen</a></code> directive to
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess control the addresses and ports on which the server listens.)
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <p>Collectively the
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess entire set of addresses (including multiple
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess results from DNS lookups) are called the vhost's
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <p>Apache automatically discriminates on the
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess basis of the HTTP <code>Host</code> header supplied by the client
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess whenever the most specific match for an IP address and port combination
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess is listed in multiple virtual hosts.</p>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <code class="directive"><a href="/mod/core.html#servername">ServerName</a></code> directive
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess may appear anywhere within the definition of a server. However,
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess each appearance overrides the previous appearance (within that
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess server). If no <code>ServerName</code> is specified, the server
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess attempts to deduce it from the server's IP address.</p>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <p>The first name-based vhost in the configuration file for a
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess given IP:port pair is significant because it is used for all
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess requests received on that address and port for which no other
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess vhost for that IP:port pair has a matching ServerName or
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess ServerAlias. It is also used for all SSL connections if the
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess server does not support <a class="glossarylink" href="/glossary.html#servernameindication" title="see glossary">Server Name Indication</a>.</p>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <p>For every vhost various default values are set. In
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess particular:</p>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <li>If a vhost has no <code class="directive"><a href="/mod/core.html#serveradmin">ServerAdmin</a></code>,
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <code class="directive"><a href="/mod/core.html#timeout">Timeout</a></code>,
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <code class="directive"><a href="/mod/core.html#keepalivetimeout">KeepAliveTimeout</a></code>,
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <code class="directive"><a href="/mod/core.html#keepalive">KeepAlive</a></code>,
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <code class="directive"><a href="/mod/core.html#maxkeepaliverequests">MaxKeepAliveRequests</a></code>,
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <code class="directive"><a href="/mod/mpm_common.html#receivebuffersize">ReceiveBufferSize</a></code>,
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess or <code class="directive"><a href="/mod/mpm_common.html#sendbuffersize">SendBufferSize</a></code>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess directive then the respective value is inherited from the
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess main server. (That is, inherited from whatever the final
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess setting of that value is in the main server.)</li>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <li>The "lookup defaults" that define the default directory
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess permissions for a vhost are merged with those of the
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess main server. This includes any per-directory configuration
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess information for any module.</li>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <li>The per-server configs for each module from the
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess main server are merged into the vhost server.</li>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <p>Essentially, the main server is treated as "defaults" or a
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess "base" on which to build each vhost. But the positioning of
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess these main server definitions in the config file is largely
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess irrelevant -- the entire config of the main server has been
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess parsed when this final merging occurs. So even if a main server
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess definition appears after a vhost definition it might affect the
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess vhost definition.</p>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <p>If the main server has no <code>ServerName</code> at this
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess point, then the hostname of the machine that <code class="program"><a href="/programs/httpd.html">httpd</a></code>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess is running on is used instead. We will call the <em>main server address
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess set</em> those IP addresses returned by a DNS lookup on the
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess name-based vhost defaults to the address given first in the
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <code>VirtualHost</code> statement defining the vhost.</p>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <p>Any vhost that includes the magic <code>_default_</code>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess wildcard is given the same <code>ServerName</code> as the
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess main server.</p>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess</div><div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess<h2><a name="hostmatching" id="hostmatching">Virtual Host Matching</a></h2>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <p>The server determines which vhost to use for a request as
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess follows:</p>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <h3><a name="hashtable" id="hashtable">IP address lookup</a></h3>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <p>When the connection is first received on some address and port,
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess the server looks for all the <code>VirtualHost</code> definitions
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess that have the same IP address and port.</p>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <p>If there are no exact matches for the address and port, then
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <p>If no matches are found, the request is served by the
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess main server.</p>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <p>If there are <code>VirtualHost</code> definitions for
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess the IP address, the next step is to decide if we have to
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess deal with an IP-based or a name-based vhost.</p>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <h3><a name="ipbased" id="ipbased">IP-based vhost</a></h3>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <p>If there is exactly one <code>VirtualHost</code> directive
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess listing the IP address and port combination that was determined
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess to be the best match, no further actions are performed and
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess the request is served from the matching vhost.</p>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <h3><a name="namebased" id="namebased">Name-based vhost</a></h3>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <p>If there are multiple <code>VirtualHost</code> directives listing
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess the IP address and port combination that was determined to be the
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess best match, the "list" in the remaining steps refers to the list of vhosts
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess that matched, in the order they were in the configuration file.</p>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <p>If the connection is using SSL, the server supports <a class="glossarylink" href="/glossary.html#servernameindication" title="see glossary">Server Name Indication</a>, and
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess the SSL client handshake includes the TLS extension with the
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess requested hostname, then that hostname is used below just like the
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <code>Host:</code> header would be used on a non-SSL connection.
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess Otherwise, the first name-based vhost whose address matched is
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess used for SSL connections. This is significant because the
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess vhost determines which certificate the server will use for the
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess connection.</p>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <p>If the request contains a <code>Host:</code> header field, the
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess list is searched for the first vhost with a matching
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <code>ServerName</code> or <code>ServerAlias</code>, and the
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess request is served from that vhost. A <code>Host:</code> header
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess field can contain a port number, but Apache always ignores it and
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess matches against the real port to which the client sent the
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess request.</p>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <p>The first vhost in the config
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess file with the specified IP address has the highest priority
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess and catches any request to an unknown server name, or a request
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess without a <code>Host:</code> header field (such as a HTTP/1.0
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess request).</p>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <h3><a name="persistent" id="persistent">Persistent connections</a></h3>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <p>The <em>IP lookup</em> described above is only done <em>once</em> for a
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess particular TCP/IP session while the <em>name lookup</em> is done on
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess connection. In other words, a client may request pages from
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess different name-based vhosts during a single persistent
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess connection.</p>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <h3><a name="absoluteURI" id="absoluteURI">Absolute URI</a></h3>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <p>If the URI from the request is an absolute URI, and its
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess hostname and port match the main server or one of the
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess configured virtual hosts <em>and</em> match the address and
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess port to which the client sent the request, then the
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess scheme/hostname/port prefix is stripped off and the remaining
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess relative URI is served by the corresponding main server or
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess virtual host. If it does not match, then the URI remains
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess untouched and the request is taken to be a proxy request.</p>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess<h3><a name="observations" id="observations">Observations</a></h3>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <li>Name-based virtual hosting is a process applied after
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess the server has selected the best matching IP-based virtual
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess host.</li>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <li>If you don't care what IP address the client has connected to, use a
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess "*" as the address of every virtual host, and name-based virtual hosting
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess is applied across all configured virtual hosts.</li>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <li><code>ServerName</code> and <code>ServerAlias</code>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess checks are never performed for an IP-based vhost.</li>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <li>Only the ordering of
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess name-based vhosts for a specific address set is significant.
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess The one name-based vhosts that comes first in the
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess configuration file has the highest priority for its
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess corresponding address set.</li>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <li>Any port in the <code>Host:</code> header field is never used during the
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess matching process. Apache always uses the real port to which
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess the client sent the request.</li>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <li>If two vhosts have an address in common, those common addresses
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess act as name-based virtual hosts implicitly. This is new behavior as of
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess 2.3.11.</li>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <li>The main server is only used to serve a request if the IP
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess address and port number to which the client connected
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess does not match any vhost (including a
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess combination (unless there is a <code>_default_</code> vhost
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess which matches that port).</li>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <li>You should never specify DNS names in
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <code>VirtualHost</code> directives because it will force
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess your server to rely on DNS to boot. Furthermore it poses a
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess security threat if you do not control the DNS for all the
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess domains listed. There's <a href="/dns-caveats.html">more
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess information</a> available on this and the next two
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess topics.</li>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <li><code>ServerName</code> should always be set for each
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess vhost. Otherwise A DNS lookup is required for each
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess vhost.</li>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess</div><div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <p>In addition to the tips on the <a href="/dns-caveats.html#tips">DNS Issues</a> page, here are
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess some further tips:</p>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <li>Place all main server definitions before any
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <code>VirtualHost</code> definitions. (This is to aid the
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess readability of the configuration -- the post-config merging
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess process makes it non-obvious that definitions mixed in around
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess virtual hosts might affect all virtual hosts.)</li>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess<p><span>Available Languages: </span><a href="/en/vhosts/details.html" title="English"> en </a> |
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess<a href="/fr/vhosts/details.html" hreflang="fr" rel="alternate" title="Fran�ais"> fr </a> |
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess<a href="/ko/vhosts/details.html" hreflang="ko" rel="alternate" title="Korean"> ko </a> |
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess<a href="/tr/vhosts/details.html" hreflang="tr" rel="alternate" title="T�rk�e"> tr </a></p>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess<p class="apache">Copyright 2012 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>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess<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[//><!--
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kessif (typeof(prettyPrint) !== undefined) {
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess prettyPrint();