fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
fd9abdda70912b99b24e3bf1a38f26fde908a74cnd<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head>
fd9abdda70912b99b24e3bf1a38f26fde908a74cnd<meta content="text/html; charset=ISO-8859-1" http-equiv="Content-Type" />
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess This file is generated from xml source: DO NOT EDIT
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
96ad5d81ee4a2cc66a4ae19893efc8aa6d06fae7jailletc<title>An In-Depth Discussion of Virtual Host Matching - Apache HTTP Server Version 2.5</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" />
d29d9ab4614ff992b0e8de6e2b88d52b6f1f153erbowen<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" />
2e545ce2450a9953665f701bb05350f0d3f26275nd<script src="/style/scripts/prettify.min.js" type="text/javascript">
5a58787efeb02a1c3f06569d019ad81fd2efa06end<link href="/images/favicon.ico" rel="shortcut icon" /></head>
af33a4994ae2ff15bc67d19ff1a7feb906745bf8rbowen<p class="menu"><a href="/mod/">Modules</a> | <a href="/mod/quickreference.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>
5a58787efeb02a1c3f06569d019ad81fd2efa06end<div class="up"><a href="./"><img title="<-" alt="<-" src="/images/left.gif" /></a></div>
3f08db06526d6901aa08c110b5bc7dde6bc39905nd<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>
ad74a0524a06bfe11b7de9e3b4ce7233ab3bd3f7nd<p><span>Available Languages: </span><a href="/en/vhosts/details.html" title="English"> en </a> |
d05d0eb4ae6d2a5e513fc3bf2555ce33da416634nd<a href="/fr/vhosts/details.html" hreflang="fr" rel="alternate" title="Fran�ais"> fr </a> |
4b3a8afbfcea8b265d179a122bf40dfedd1ce280takashi<a href="/ko/vhosts/details.html" hreflang="ko" rel="alternate" title="Korean"> ko </a> |
f086b4b402fa9a2fefc7dda85de2a3cc1cd0a654rjung<a href="/tr/vhosts/details.html" hreflang="tr" rel="alternate" title="T�rk�e"> tr </a></p>
15107611640cec4e666dd7e2e1dee15c270e9e98rbowen <p>This document attempts to explain
15107611640cec4e666dd7e2e1dee15c270e9e98rbowen exactly what Apache HTTP Server does when deciding what virtual host to
15107611640cec4e666dd7e2e1dee15c270e9e98rbowen serve a request from.</p>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier <p>Most users should read about <a href="name-based.html#namevip">
60a4b2c422dcbb08a554fb193105c08da592718bpoirier Name-based vs. IP-based Virtual Hosts</a> to decide which type they
60a4b2c422dcbb08a554fb193105c08da592718bpoirier want to use, then read more about <a href="name-based.html">name-based</a>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier or <a href="ip-based.html">IP-based</a> virtualhosts, and then see
60a4b2c422dcbb08a554fb193105c08da592718bpoirier <p>If you want to understand all the details, then you can
60a4b2c422dcbb08a554fb193105c08da592718bpoirier come back to this page.</p>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier<div id="quickview"><ul id="toc"><li><img alt="" src="/images/down.gif" /> <a href="#configparsing">Configuration File</a></li>
5a58787efeb02a1c3f06569d019ad81fd2efa06end<li><img alt="" src="/images/down.gif" /> <a href="#hostmatching">Virtual Host Matching</a></li>
5a58787efeb02a1c3f06569d019ad81fd2efa06end<li><img alt="" src="/images/down.gif" /> <a href="#tips">Tips</a></li>
30471a4650391f57975f60bbb6e4a90be7b284bfhumbedooh</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><ul class="seealso"><li><a href="#comments_section">Comments</a></li></ul></div>
5a58787efeb02a1c3f06569d019ad81fd2efa06end<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier<h2><a name="configparsing" id="configparsing">Configuration File</a></h2>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier <p>There is a <em>main server</em> which consists of all the
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess definitions appearing outside of
60a4b2c422dcbb08a554fb193105c08da592718bpoirier <p>There are virtual
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <code class="directive"><a href="/mod/core.html#virtualhost"><VirtualHost></a></code>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess sections.</p>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier <p>Each <code>VirtualHost</code> directive includes one
60a4b2c422dcbb08a554fb193105c08da592718bpoirier or more addresses and optional ports.</p>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier <p>Hostnames can be used in place of IP addresses in a virtual
60a4b2c422dcbb08a554fb193105c08da592718bpoirier host definition, but they are resolved at startup and if any name
60a4b2c422dcbb08a554fb193105c08da592718bpoirier resolutions fail, those virtual host definitions are ignored.
60a4b2c422dcbb08a554fb193105c08da592718bpoirier This is, therefore, not recommended.</p>
6e14faf37935e36804b8bad802bc9dd58f3cf65dsf <p>The address can be specified as
60a4b2c422dcbb08a554fb193105c08da592718bpoirier other vhost has the explicit address on which the request was
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf received. </p>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier <p>The address appearing in the <code>VirtualHost</code>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier directive can have an optional port. If the port is unspecified,
60a4b2c422dcbb08a554fb193105c08da592718bpoirier it is treated as a wildcard port, which can also be indicated
60a4b2c422dcbb08a554fb193105c08da592718bpoirier The wildcard port matches any port.</p>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier <p>(Port numbers specified in the <code>VirtualHost</code> directive do
60a4b2c422dcbb08a554fb193105c08da592718bpoirier not influence what port numbers Apache will listen on, they only control
60a4b2c422dcbb08a554fb193105c08da592718bpoirier which <code>VirtualHost</code> will be selected to handle a request.
ad79e6242f42c1915d14628f8bf44f04b129716arbowen Use the <code class="directive"><a href="/mod/mpm_common.html#listen">Listen</a></code> directive to
60a4b2c422dcbb08a554fb193105c08da592718bpoirier control the addresses and ports on which the server listens.)
60a4b2c422dcbb08a554fb193105c08da592718bpoirier <p>Collectively the
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf entire set of addresses (including multiple
60a4b2c422dcbb08a554fb193105c08da592718bpoirier results from DNS lookups) are called the vhost's
6e14faf37935e36804b8bad802bc9dd58f3cf65dsf <p>Apache automatically discriminates on the
6e14faf37935e36804b8bad802bc9dd58f3cf65dsf basis of the HTTP <code>Host</code> header supplied by the client
6e14faf37935e36804b8bad802bc9dd58f3cf65dsf whenever the most specific match for an IP address and port combination
6e14faf37935e36804b8bad802bc9dd58f3cf65dsf is listed in multiple virtual hosts.</p>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier <code class="directive"><a href="/mod/core.html#servername">ServerName</a></code> directive
60a4b2c422dcbb08a554fb193105c08da592718bpoirier may appear anywhere within the definition of a server. However,
60a4b2c422dcbb08a554fb193105c08da592718bpoirier each appearance overrides the previous appearance (within that
60a4b2c422dcbb08a554fb193105c08da592718bpoirier server). If no <code>ServerName</code> is specified, the server
60a4b2c422dcbb08a554fb193105c08da592718bpoirier attempts to deduce it from the server's IP address.</p>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier <p>The first name-based vhost in the configuration file for a
60a4b2c422dcbb08a554fb193105c08da592718bpoirier given IP:port pair is significant because it is used for all
60a4b2c422dcbb08a554fb193105c08da592718bpoirier requests received on that address and port for which no other
60a4b2c422dcbb08a554fb193105c08da592718bpoirier vhost for that IP:port pair has a matching ServerName or
60a4b2c422dcbb08a554fb193105c08da592718bpoirier ServerAlias. It is also used for all SSL connections if the
60a4b2c422dcbb08a554fb193105c08da592718bpoirier server does not support <a class="glossarylink" href="/glossary.html#servernameindication" title="see glossary">Server Name Indication</a>.</p>
9967f2fc7dda1d28667d039ad2c85fe9eda080accovener <p>The complete list of names in the <code>VirtualHost</code>
a99c5d4cc3cab6a62b04d52000dbc22ce1fa2d94coar directive are treated just like a (non wildcard) <code>ServerAlias</code>
9967f2fc7dda1d28667d039ad2c85fe9eda080accovener (but are not overridden by any <code>ServerAlias</code> statement).</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>,
ad79e6242f42c1915d14628f8bf44f04b129716arbowen <code class="directive"><a href="/mod/mpm_common.html#receivebuffersize">ReceiveBufferSize</a></code>,
ad79e6242f42c1915d14628f8bf44f04b129716arbowen or <code class="directive"><a href="/mod/mpm_common.html#sendbuffersize">SendBufferSize</a></code>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess directive then the respective value is inherited from the
60a4b2c422dcbb08a554fb193105c08da592718bpoirier main server. (That is, inherited from whatever the final
60a4b2c422dcbb08a554fb193105c08da592718bpoirier 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
60a4b2c422dcbb08a554fb193105c08da592718bpoirier 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
60a4b2c422dcbb08a554fb193105c08da592718bpoirier main server are merged into the vhost server.</li>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier <p>Essentially, the main server is treated as "defaults" or a
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess "base" on which to build each vhost. But the positioning of
60a4b2c422dcbb08a554fb193105c08da592718bpoirier these main server definitions in the config file is largely
60a4b2c422dcbb08a554fb193105c08da592718bpoirier irrelevant -- the entire config of the main server has been
60a4b2c422dcbb08a554fb193105c08da592718bpoirier 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>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier <p>If the main server has no <code>ServerName</code> at this
9bcfc3697a91b5215893a7d0206865b13fc72148nd point, then the hostname of the machine that <code class="program"><a href="/programs/httpd.html">httpd</a></code>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier 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
60a4b2c422dcbb08a554fb193105c08da592718bpoirier main server.</p>
5a58787efeb02a1c3f06569d019ad81fd2efa06end</div><div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
5a58787efeb02a1c3f06569d019ad81fd2efa06end<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>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier <h3><a name="hashtable" id="hashtable">IP address lookup</a></h3>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier <p>When the connection is first received on some address and port,
60a4b2c422dcbb08a554fb193105c08da592718bpoirier the server looks for all the <code>VirtualHost</code> definitions
60a4b2c422dcbb08a554fb193105c08da592718bpoirier that have the same IP address and port.</p>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier <p>If there are no exact matches for the address and port, then
60a4b2c422dcbb08a554fb193105c08da592718bpoirier wildcard (<code>*</code>) matches are considered.</p>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier <p>If no matches are found, the request is served by the
60a4b2c422dcbb08a554fb193105c08da592718bpoirier main server.</p>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier <p>If there are <code>VirtualHost</code> definitions for
60a4b2c422dcbb08a554fb193105c08da592718bpoirier the IP address, the next step is to decide if we have to
60a4b2c422dcbb08a554fb193105c08da592718bpoirier deal with an IP-based or a name-based vhost.</p>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <h3><a name="ipbased" id="ipbased">IP-based vhost</a></h3>
6e14faf37935e36804b8bad802bc9dd58f3cf65dsf <p>If there is exactly one <code>VirtualHost</code> directive
4cb65c31bc681540ea623e1cb2bdd09749fb8d7esf listing the IP address and port combination that was determined
6e14faf37935e36804b8bad802bc9dd58f3cf65dsf to be the best match, no further actions are performed and
6e14faf37935e36804b8bad802bc9dd58f3cf65dsf the request is served from the matching vhost.</p>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <h3><a name="namebased" id="namebased">Name-based vhost</a></h3>
4cb65c31bc681540ea623e1cb2bdd09749fb8d7esf <p>If there are multiple <code>VirtualHost</code> directives listing
6e14faf37935e36804b8bad802bc9dd58f3cf65dsf the IP address and port combination that was determined to be the
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf best match, the "list" in the remaining steps refers to the list of vhosts
6e14faf37935e36804b8bad802bc9dd58f3cf65dsf that matched, in the order they were in the configuration file.</p>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier <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
60a4b2c422dcbb08a554fb193105c08da592718bpoirier the SSL client handshake includes the TLS extension with the
60a4b2c422dcbb08a554fb193105c08da592718bpoirier requested hostname, then that hostname is used below just like the
60a4b2c422dcbb08a554fb193105c08da592718bpoirier <code>Host:</code> header would be used on a non-SSL connection.
60a4b2c422dcbb08a554fb193105c08da592718bpoirier Otherwise, the first name-based vhost whose address matched is
60a4b2c422dcbb08a554fb193105c08da592718bpoirier used for SSL connections. This is significant because the
60a4b2c422dcbb08a554fb193105c08da592718bpoirier vhost determines which certificate the server will use for the
60a4b2c422dcbb08a554fb193105c08da592718bpoirier connection.</p>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier <p>If the request contains a <code>Host:</code> header field, the
60a4b2c422dcbb08a554fb193105c08da592718bpoirier list is searched for the first vhost with a matching
60a4b2c422dcbb08a554fb193105c08da592718bpoirier <code>ServerName</code> or <code>ServerAlias</code>, and the
60a4b2c422dcbb08a554fb193105c08da592718bpoirier request is served from that vhost. A <code>Host:</code> header
60a4b2c422dcbb08a554fb193105c08da592718bpoirier 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>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier <p>The first vhost in the config
60a4b2c422dcbb08a554fb193105c08da592718bpoirier file with the specified IP address has the highest priority
60a4b2c422dcbb08a554fb193105c08da592718bpoirier and catches any request to an unknown server name, or a request
60a4b2c422dcbb08a554fb193105c08da592718bpoirier without a <code>Host:</code> header field (such as a HTTP/1.0
60a4b2c422dcbb08a554fb193105c08da592718bpoirier request).</p>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess <h3><a name="persistent" id="persistent">Persistent connections</a></h3>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier <p>The <em>IP lookup</em> described above is only done <em>once</em> for a
60a4b2c422dcbb08a554fb193105c08da592718bpoirier particular TCP/IP session while the <em>name lookup</em> is done on
60a4b2c422dcbb08a554fb193105c08da592718bpoirier 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>
6e14faf37935e36804b8bad802bc9dd58f3cf65dsf <li>Name-based virtual hosting is a process applied after
6e14faf37935e36804b8bad802bc9dd58f3cf65dsf the server has selected the best matching IP-based virtual
6e14faf37935e36804b8bad802bc9dd58f3cf65dsf host.</li>
6e14faf37935e36804b8bad802bc9dd58f3cf65dsf <li>If you don't care what IP address the client has connected to, use a
6e14faf37935e36804b8bad802bc9dd58f3cf65dsf "*" as the address of every virtual host, and name-based virtual hosting
6e14faf37935e36804b8bad802bc9dd58f3cf65dsf is applied across all configured virtual hosts.</li>
fefb8b844b6286bfc41bb2e0c4cc003b8e7d4ff2kess checks are never performed for an IP-based vhost.</li>
6e14faf37935e36804b8bad802bc9dd58f3cf65dsf <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>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier <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>
6e14faf37935e36804b8bad802bc9dd58f3cf65dsf <li>If two vhosts have an address in common, those common addresses
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf act as name-based virtual hosts implicitly. This is new behavior as of
6e14faf37935e36804b8bad802bc9dd58f3cf65dsf 2.3.11.</li>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier <li>The main server is only used to serve a request if the IP
9a58dc6a2b26ec128b1270cf48810e705f1a90dbsf address and port number to which the client connected
60a4b2c422dcbb08a554fb193105c08da592718bpoirier 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>
5a58787efeb02a1c3f06569d019ad81fd2efa06end</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>
60a4b2c422dcbb08a554fb193105c08da592718bpoirier <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>
ad74a0524a06bfe11b7de9e3b4ce7233ab3bd3f7nd<p><span>Available Languages: </span><a href="/en/vhosts/details.html" title="English"> en </a> |
d05d0eb4ae6d2a5e513fc3bf2555ce33da416634nd<a href="/fr/vhosts/details.html" hreflang="fr" rel="alternate" title="Fran�ais"> fr </a> |
4b3a8afbfcea8b265d179a122bf40dfedd1ce280takashi<a href="/ko/vhosts/details.html" hreflang="ko" rel="alternate" title="Korean"> ko </a> |
f086b4b402fa9a2fefc7dda85de2a3cc1cd0a654rjung<a href="/tr/vhosts/details.html" hreflang="tr" rel="alternate" title="T�rk�e"> tr </a></p>
727872d18412fc021f03969b8641810d8896820bhumbedooh</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&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>
727872d18412fc021f03969b8641810d8896820bhumbedoohvar comments_shortname = 'httpd';
cc7e1025de9ac63bd4db6fe7f71c158b2cf09fe4humbedoohvar comments_identifier = 'http://httpd.apache.org/docs/trunk/vhosts/details.html';
0d0ba3a410038e179b695446bb149cce6264e0abnd(function(w, d) {
cc7e1025de9ac63bd4db6fe7f71c158b2cf09fe4humbedooh if (w.location.hostname.toLowerCase() == "httpd.apache.org") {
727872d18412fc021f03969b8641810d8896820bhumbedooh d.write('<div id="comments_thread"><\/div>');
0d0ba3a410038e179b695446bb149cce6264e0abnd var s = d.createElement('script');
ac082aefa89416cbdc9a1836eaf3bed9698201c8humbedooh s.src = 'https://comments.apache.org/show_comments.lua?site=' + comments_shortname + '&page=' + comments_identifier;
0d0ba3a410038e179b695446bb149cce6264e0abnd (d.getElementsByTagName('head')[0] || d.getElementsByTagName('body')[0]).appendChild(s);
727872d18412fc021f03969b8641810d8896820bhumbedooh d.write('<div id="comments_thread">Comments are disabled for this page at the moment.<\/div>');
0d0ba3a410038e179b695446bb149cce6264e0abnd})(window, document);
205f749042ed530040a4f0080dbcb47ceae8a374rjung<p class="apache">Copyright 2015 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>
af33a4994ae2ff15bc67d19ff1a7feb906745bf8rbowen<p class="menu"><a href="/mod/">Modules</a> | <a href="/mod/quickreference.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[//><!--
0d0ba3a410038e179b695446bb149cce6264e0abndif (typeof(prettyPrint) !== 'undefined') {
7fec19672a491661b2fe4b29f685bc7f4efa64d4nd prettyPrint();