details.html.en revision 19737f4fbef1805f9c3e9e045bb6d710a1e5e10f
ca7a44a6825a4ec88afaa6e4f23fb0fb7c52d3dfwrowe<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
ca7a44a6825a4ec88afaa6e4f23fb0fb7c52d3dfwrowe<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><!--
ca7a44a6825a4ec88afaa6e4f23fb0fb7c52d3dfwrowe XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
ca7a44a6825a4ec88afaa6e4f23fb0fb7c52d3dfwrowe This file is generated from xml source: DO NOT EDIT
ca7a44a6825a4ec88afaa6e4f23fb0fb7c52d3dfwrowe XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
ca7a44a6825a4ec88afaa6e4f23fb0fb7c52d3dfwrowe<title>An In-Depth Discussion of Virtual Host Matching - Apache HTTP Server</title>
ca7a44a6825a4ec88afaa6e4f23fb0fb7c52d3dfwrowe<link href="/style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
ca7a44a6825a4ec88afaa6e4f23fb0fb7c52d3dfwrowe<link href="/style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
ca7a44a6825a4ec88afaa6e4f23fb0fb7c52d3dfwrowe<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" />
ca7a44a6825a4ec88afaa6e4f23fb0fb7c52d3dfwrowe<script src="/style/scripts/prettify.js" type="text/javascript">
ca7a44a6825a4ec88afaa6e4f23fb0fb7c52d3dfwrowe<link href="/images/favicon.ico" rel="shortcut icon" /></head>
ca7a44a6825a4ec88afaa6e4f23fb0fb7c52d3dfwrowe<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>
ca7a44a6825a4ec88afaa6e4f23fb0fb7c52d3dfwrowe<div class="up"><a href="./"><img title="<-" alt="<-" src="/images/left.gif" /></a></div>
ca7a44a6825a4ec88afaa6e4f23fb0fb7c52d3dfwrowe<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>
ca7a44a6825a4ec88afaa6e4f23fb0fb7c52d3dfwrowe<p><span>Available Languages: </span><a href="/en/vhosts/details.html" title="English"> en </a> |
ca7a44a6825a4ec88afaa6e4f23fb0fb7c52d3dfwrowe<a href="/fr/vhosts/details.html" hreflang="fr" rel="alternate" title="Fran�ais"> fr </a> |
ca7a44a6825a4ec88afaa6e4f23fb0fb7c52d3dfwrowe<a href="/ko/vhosts/details.html" hreflang="ko" rel="alternate" title="Korean"> ko </a> |
ca7a44a6825a4ec88afaa6e4f23fb0fb7c52d3dfwrowe<a href="/tr/vhosts/details.html" hreflang="tr" rel="alternate" title="T�rk�e"> tr </a></p>
ca7a44a6825a4ec88afaa6e4f23fb0fb7c52d3dfwrowe <p>This document attempts to explain
ca7a44a6825a4ec88afaa6e4f23fb0fb7c52d3dfwrowe exactly what Apache HTTP Server does when deciding what virtual host to
ca7a44a6825a4ec88afaa6e4f23fb0fb7c52d3dfwrowe serve a request from.</p>
ca7a44a6825a4ec88afaa6e4f23fb0fb7c52d3dfwrowe <p>Most users should read about <a href="name-based.html#namevip">
ca7a44a6825a4ec88afaa6e4f23fb0fb7c52d3dfwrowe Name-based vs. IP-based Virtual Hosts</a> to decide which type they
ca7a44a6825a4ec88afaa6e4f23fb0fb7c52d3dfwrowe want to use, then read more about <a href="name-based.html">name-based</a>
ca7a44a6825a4ec88afaa6e4f23fb0fb7c52d3dfwrowe or <a href="ip-based.html">IP-based</a> virtualhosts, and then see
ca7a44a6825a4ec88afaa6e4f23fb0fb7c52d3dfwrowe <p>If you want to understand all the details, then you can
ca7a44a6825a4ec88afaa6e4f23fb0fb7c52d3dfwrowe come back to this page.</p>
ca7a44a6825a4ec88afaa6e4f23fb0fb7c52d3dfwrowe<div id="quickview"><ul id="toc"><li><img alt="" src="/images/down.gif" /> <a href="#configparsing">Configuration File</a></li>
ca7a44a6825a4ec88afaa6e4f23fb0fb7c52d3dfwrowe<li><img alt="" src="/images/down.gif" /> <a href="#hostmatching">Virtual Host Matching</a></li>
ca7a44a6825a4ec88afaa6e4f23fb0fb7c52d3dfwrowe<li><img alt="" src="/images/down.gif" /> <a href="#tips">Tips</a></li>
ca7a44a6825a4ec88afaa6e4f23fb0fb7c52d3dfwrowe</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>
ca7a44a6825a4ec88afaa6e4f23fb0fb7c52d3dfwrowe<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
ca7a44a6825a4ec88afaa6e4f23fb0fb7c52d3dfwrowe<h2><a name="configparsing" id="configparsing">Configuration File</a></h2>
ca7a44a6825a4ec88afaa6e4f23fb0fb7c52d3dfwrowe <p>There is a <em>main server</em> which consists of all the
ca7a44a6825a4ec88afaa6e4f23fb0fb7c52d3dfwrowe definitions appearing outside of
ca7a44a6825a4ec88afaa6e4f23fb0fb7c52d3dfwrowe <p>There are virtual
ca7a44a6825a4ec88afaa6e4f23fb0fb7c52d3dfwrowe <code class="directive"><a href="/mod/core.html#virtualhost"><VirtualHost></a></code>
ca7a44a6825a4ec88afaa6e4f23fb0fb7c52d3dfwrowe sections.</p>
ca7a44a6825a4ec88afaa6e4f23fb0fb7c52d3dfwrowe <p>Each <code>VirtualHost</code> directive includes one
ca7a44a6825a4ec88afaa6e4f23fb0fb7c52d3dfwrowe or more addresses and optional ports.</p>
ca7a44a6825a4ec88afaa6e4f23fb0fb7c52d3dfwrowe <p>Hostnames can be used in place of IP addresses in a virtual
ca7a44a6825a4ec88afaa6e4f23fb0fb7c52d3dfwrowe host definition, but they are resolved at startup and if any name
ca7a44a6825a4ec88afaa6e4f23fb0fb7c52d3dfwrowe resolutions fail, those virtual host definitions are ignored.
ca7a44a6825a4ec88afaa6e4f23fb0fb7c52d3dfwrowe This is, therefore, not recommended.</p>
ca7a44a6825a4ec88afaa6e4f23fb0fb7c52d3dfwrowe <p>The address can be specified as
ca7a44a6825a4ec88afaa6e4f23fb0fb7c52d3dfwrowe other vhost has the explicit address on which the request was
ca7a44a6825a4ec88afaa6e4f23fb0fb7c52d3dfwrowe received. </p>
ca7a44a6825a4ec88afaa6e4f23fb0fb7c52d3dfwrowe <p>The address appearing in the <code>VirtualHost</code>
ca7a44a6825a4ec88afaa6e4f23fb0fb7c52d3dfwrowe directive can have an optional port. If the port is unspecified,
ca7a44a6825a4ec88afaa6e4f23fb0fb7c52d3dfwrowe it is treated as a wildcard port, which can also be indicated
ca7a44a6825a4ec88afaa6e4f23fb0fb7c52d3dfwrowe The wildcard port matches any port.</p>
ca7a44a6825a4ec88afaa6e4f23fb0fb7c52d3dfwrowe <p>(Port numbers specified in the <code>VirtualHost</code> directive do
ca7a44a6825a4ec88afaa6e4f23fb0fb7c52d3dfwrowe not influence what port numbers Apache will listen on, they only control
ca7a44a6825a4ec88afaa6e4f23fb0fb7c52d3dfwrowe which <code>VirtualHost</code> will be selected to handle a request.
ca7a44a6825a4ec88afaa6e4f23fb0fb7c52d3dfwrowe Use the <code class="directive"><a href="/mod/mpm_common.html#listen">Listen</a></code> directive to
ca7a44a6825a4ec88afaa6e4f23fb0fb7c52d3dfwrowe control the addresses and ports on which the server listens.)
ca7a44a6825a4ec88afaa6e4f23fb0fb7c52d3dfwrowe <p>Collectively the
ca7a44a6825a4ec88afaa6e4f23fb0fb7c52d3dfwrowe entire set of addresses (including multiple
ca7a44a6825a4ec88afaa6e4f23fb0fb7c52d3dfwrowe results from DNS lookups) are called the vhost's
ca7a44a6825a4ec88afaa6e4f23fb0fb7c52d3dfwrowe <p>Apache automatically discriminates on the
ca7a44a6825a4ec88afaa6e4f23fb0fb7c52d3dfwrowe basis of the HTTP <code>Host</code> header supplied by the client
ca7a44a6825a4ec88afaa6e4f23fb0fb7c52d3dfwrowe whenever the most specific match for an IP address and port combination
ca7a44a6825a4ec88afaa6e4f23fb0fb7c52d3dfwrowe is listed in multiple virtual hosts.</p>
ca7a44a6825a4ec88afaa6e4f23fb0fb7c52d3dfwrowe <code class="directive"><a href="/mod/core.html#servername">ServerName</a></code> directive
ca7a44a6825a4ec88afaa6e4f23fb0fb7c52d3dfwrowe may appear anywhere within the definition of a server. However,
ca7a44a6825a4ec88afaa6e4f23fb0fb7c52d3dfwrowe each appearance overrides the previous appearance (within that
ca7a44a6825a4ec88afaa6e4f23fb0fb7c52d3dfwrowe server). If no <code>ServerName</code> is specified, the server
ca7a44a6825a4ec88afaa6e4f23fb0fb7c52d3dfwrowe attempts to deduce it from the server's IP address.</p>
ca7a44a6825a4ec88afaa6e4f23fb0fb7c52d3dfwrowe <p>The first name-based vhost in the configuration file for a
ca7a44a6825a4ec88afaa6e4f23fb0fb7c52d3dfwrowe given IP:port pair is significant because it is used for all
ca7a44a6825a4ec88afaa6e4f23fb0fb7c52d3dfwrowe requests received on that address and port for which no other
ca7a44a6825a4ec88afaa6e4f23fb0fb7c52d3dfwrowe vhost for that IP:port pair has a matching ServerName or
ca7a44a6825a4ec88afaa6e4f23fb0fb7c52d3dfwrowe ServerAlias. It is also used for all SSL connections if the
ca7a44a6825a4ec88afaa6e4f23fb0fb7c52d3dfwrowe server does not support <a class="glossarylink" href="/glossary.html#servernameindication" title="see glossary">Server Name Indication</a>.</p>
<li>If a vhost has no <code class="directive"><a href="/mod/core.html#serveradmin">ServerAdmin</a></code>,
<code class="directive"><a href="/mod/core.html#maxkeepaliverequests">MaxKeepAliveRequests</a></code>,
<code class="directive"><a href="/mod/mpm_common.html#receivebuffersize">ReceiveBufferSize</a></code>,
point, then the hostname of the machine that <code class="program"><a href="/programs/httpd.html">httpd</a></code>
<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
<p><span>Available Languages: </span><a href="/en/vhosts/details.html" title="English"> en </a> |
<a href="/fr/vhosts/details.html" hreflang="fr" rel="alternate" title="Fran�ais"> fr </a> |
<a href="/tr/vhosts/details.html" hreflang="tr" rel="alternate" title="T�rk�e"> tr </a></p>
</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>This section is experimental!</strong><br />Comments placed here should not be expected
to last beyond the testing phase of this system, nor do we in any way guarantee that we'll read them.</div>
var disqus_identifier = window.location.href.replace(/(current|trunk)/, "2.4").replace(/\/[a-z]{2}\//, "/").replace(window.location.protocol, "http:") + '.' + lang;
if (disqus_identifier.indexOf("httpd.apache.org") == -1) {
document.write('<div id="disqus_thread">\n</div>');
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = window.location.protocol + '//' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
document.write("Comments have been disabled for offline viewing.");
<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>
<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[//><!--