⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 name-based.html.en

📁 最新apache的源代码
💻 EN
📖 第 1 页 / 共 2 页
字号:
<?xml version="1.0" encoding="ISO-8859-1"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><!--        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX              This file is generated from xml source: DO NOT EDIT        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX      --><title>Name-based Virtual Host Support - Apache HTTP Server</title><link href="../style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" /><link href="../style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" /><link href="../style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" /><link href="../images/favicon.ico" rel="shortcut icon" /></head><body id="manual-page"><div id="page-header"><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><p class="apache">Apache HTTP Server Version 2.0</p><img alt="" src="../images/feather.gif" /></div><div class="up"><a href="./"><img title="&lt;-" alt="&lt;-" src="../images/left.gif" /></a></div><div id="path"><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-project/">Documentation</a> &gt; <a href="../">Version 2.0</a> &gt; <a href="./">Virtual Hosts</a></div><div id="page-content"><div id="preamble"><h1>Name-based Virtual Host Support</h1><div class="toplang"><p><span>Available Languages: </span><a href="../de/vhosts/name-based.html" hreflang="de" rel="alternate" title="Deutsch">&nbsp;de&nbsp;</a> |<a href="../en/vhosts/name-based.html" title="English">&nbsp;en&nbsp;</a> |<a href="../es/vhosts/name-based.html" hreflang="es" rel="alternate" title="Espa駉l">&nbsp;es&nbsp;</a> |<a href="../ja/vhosts/name-based.html" hreflang="ja" rel="alternate" title="Japanese">&nbsp;ja&nbsp;</a> |<a href="../ko/vhosts/name-based.html" hreflang="ko" rel="alternate" title="Korean">&nbsp;ko&nbsp;</a></p></div>    <p>This document describes when and how to use name-based virtual hosts.</p></div><div id="quickview"><ul id="toc"><li><img alt="" src="../images/down.gif" /> <a href="#namevip">Name-based vs. IP-based Virtual Hosts</a></li><li><img alt="" src="../images/down.gif" /> <a href="#using">Using Name-based Virtual Hosts</a></li><li><img alt="" src="../images/down.gif" /> <a href="#compat">Compatibility with Older Browsers</a></li></ul><h3>See also</h3><ul class="seealso"><li><a href="ip-based.html">IP-based Virtual Host Support</a></li><li><a href="details.html">An In-Depth Discussion of Virtual Host Matching</a></li><li><a href="mass.html">Dynamically configured mass virtual hosting</a></li><li><a href="examples.html">Virtual Host examples for common setups</a></li><li><a href="examples.html#serverpath">ServerPath configuration example</a></li></ul></div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div><div class="section"><h2><a name="namevip" id="namevip">Name-based vs. IP-based Virtual Hosts</a></h2>    <p>IP-based virtual hosts use the IP address of the connection to    determine the correct virtual host to serve.  Therefore you need to    have a separate IP address for each host.  With name-based virtual    hosting, the server relies on the client to report the hostname as    part of the HTTP headers.  Using this technique, many different hosts    can share the same IP address.</p>    <p>Name-based virtual hosting is usually simpler, since you need    only configure your DNS server to map each hostname to the correct    IP address and then configure the Apache HTTP Server to recognize    the different hostnames.  Name-based virtual hosting also eases    the demand for scarce IP addresses.  Therefore you should use    name-based virtual hosting unless there is a specific reason to    choose IP-based virtual hosting.  Some reasons why you might consider    using IP-based virtual hosting:</p>    <ul>        <li>Some ancient clients are not compatible with name-based virtual        hosting.  For name-based virtual hosting to work, the client must send        the HTTP Host header.  This is required by HTTP/1.1, and is        implemented by all modern HTTP/1.0 browsers as an extension.  If you        need to support obsolete clients and still use name-based virtual        hosting, a possible technique is discussed at the end of this        document.</li>        <li>Name-based virtual hosting cannot be used with SSL secure servers        because of the nature of the SSL protocol.</li>        <li>Some operating systems and network equipment implement bandwidth        management techniques that cannot differentiate between hosts unless        they are on separate IP addresses.</li>    </ul></div><div class="top"><a href="#page-header"><img alt="top" src="../images/up.gif" /></a></div><div class="section"><h2><a name="using" id="using">Using Name-based Virtual Hosts</a></h2><table class="related"><tr><th>Related Modules</th><th>Related Directives</th></tr><tr><td><ul><li><code class="module"><a href="../mod/core.html">core</a></code></li></ul></td><td><ul><li><code class="directive"><a href="../mod/core.html#documentroot">DocumentRoot</a></code></li><li><code class="directive"><a href="../mod/core.html#namevirtualhost">NameVirtualHost</a></code></li><li><code class="directive"><a href="../mod/core.html#serveralias">ServerAlias</a></code></li><li><code class="directive"><a href="../mod/core.html#servername">ServerName</a></code></li><li><code class="directive"><a href="../mod/core.html#serverpath">ServerPath</a></code></li><li><code class="directive"><a href="../mod/core.html#virtualhost">&lt;VirtualHost&gt;</a></code></li></ul></td></tr></table>    <p>To use name-based virtual hosting, you must designate the IP    address (and possibly port) on the server that will be accepting    requests for the hosts.  This is configured using the <code class="directive"><a href="../mod/core.html#namevirtualhost">NameVirtualHost</a></code> directive.    In the normal case where any and all IP addresses on the server should    be used, you can use <code>*</code> as the argument to <code class="directive"><a href="../mod/core.html#namevirtualhost">NameVirtualHost</a></code>. If you're planning to use    multiple ports (e.g. running SSL) you should add a Port to the argument,    such as <code>*:80</code>. Note that mentioning an IP address in a    <code class="directive"><a href="../mod/core.html#namevirtualhost">NameVirtualHost</a></code> directive does not    automatically make the server listen to that IP address. See    <a href="../bind.html">Setting which addresses and ports Apache uses</a>    for more details. In addition, any IP address specified here must be    associated with a network interface	on the server.</p>    <p>The next step is to create a <code class="directive"><a href="../mod/core.html#virtualhost">&lt;VirtualHost&gt;</a></code> block for    each different host that you would like to serve. The argument to the    <code class="directive"><a href="../mod/core.html#virtualhost">&lt;VirtualHost&gt;</a></code> directive    should be the same as the argument to the <code class="directive"><a href="../mod/core.html#namevirtualhost">NameVirtualHost</a></code> directive (ie, an IP address,    or <code>*</code> for all addresses).  Inside each <code class="directive"><a href="../mod/core.html#virtualhost">&lt;VirtualHost&gt;</a></code> block, you will need at minimum a    <code class="directive"><a href="../mod/core.html#servername">ServerName</a></code> directive to designate    which host is served and a <code class="directive"><a href="../mod/core.html#documentroot">DocumentRoot</a></code>    directive to show where in the filesystem the content for that host    lives.</p>    <div class="note"><h3>Main host goes away</h3>        <p>If you are adding virtual hosts to an existing web server, you        must also create a <code class="directive"><a href="../mod/core.html#virtualhost">&lt;VirtualHost&gt;</a></code> block for the existing host. The <code class="directive"><a href="../mod/core.html#servername">ServerName</a></code> and <code class="directive"><a href="../mod/core.html#documentroot">DocumentRoot</a></code> included in this virtual host should be the        same as the global <code class="directive"><a href="../mod/core.html#servername">ServerName</a></code> and        <code class="directive"><a href="../mod/core.html#documentroot">DocumentRoot</a></code>. List this virtual        host first in the configuration file so that it will act as the default        host.</p>    </div>    <p>For example, suppose that you are serving the domain    <code>www.domain.tld</code> and you wish to add the virtual host    <code>www.otherdomain.tld</code>, which points at the same IP address.    Then you simply add the following to <code>httpd.conf</code>:</p>    <div class="example"><p><code>        NameVirtualHost *:80<br />        <br />        &lt;VirtualHost *:80&gt;<br />        <span class="indent">            ServerName www.domain.tld<br />            ServerAlias domain.tld *.domain.tld<br />            DocumentRoot /www/domain<br />        </span>        &lt;/VirtualHost&gt;<br />

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -