examples.html.en revision 8559a67073808d84d85bb5dd552d4247caafe709
14d5b1a7866541c4eb974f2d213d2aea59743c95wrowe<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
14d5b1a7866541c4eb974f2d213d2aea59743c95wrowe<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head><!--
14d5b1a7866541c4eb974f2d213d2aea59743c95wrowe XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
14d5b1a7866541c4eb974f2d213d2aea59743c95wrowe This file is generated from xml source: DO NOT EDIT
14d5b1a7866541c4eb974f2d213d2aea59743c95wrowe XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
14d5b1a7866541c4eb974f2d213d2aea59743c95wrowe<title>VirtualHost Examples - Apache HTTP Server</title>
14d5b1a7866541c4eb974f2d213d2aea59743c95wrowe<link href="/style/css/manual.css" rel="stylesheet" media="all" type="text/css" title="Main stylesheet" />
14d5b1a7866541c4eb974f2d213d2aea59743c95wrowe<link href="/style/css/manual-loose-100pc.css" rel="alternate stylesheet" media="all" type="text/css" title="No Sidebar - Default font size" />
14d5b1a7866541c4eb974f2d213d2aea59743c95wrowe<link href="/style/css/manual-print.css" rel="stylesheet" media="print" type="text/css" />
14d5b1a7866541c4eb974f2d213d2aea59743c95wrowe<link href="/images/favicon.ico" rel="shortcut icon" /></head>
14d5b1a7866541c4eb974f2d213d2aea59743c95wrowe<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>
14d5b1a7866541c4eb974f2d213d2aea59743c95wrowe<div class="up"><a href="./"><img title="<-" alt="<-" src="/images/left.gif" /></a></div>
14d5b1a7866541c4eb974f2d213d2aea59743c95wrowe<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.3</a> > <a href="./">Virtual Hosts</a></div><div id="page-content"><div id="preamble"><h1>VirtualHost Examples</h1>
14d5b1a7866541c4eb974f2d213d2aea59743c95wrowe<p><span>Available Languages: </span><a href="/en/vhosts/examples.html" title="English"> en </a> |
14d5b1a7866541c4eb974f2d213d2aea59743c95wrowe<a href="/fr/vhosts/examples.html" hreflang="fr" rel="alternate" title="Fran�ais"> fr </a> |
14d5b1a7866541c4eb974f2d213d2aea59743c95wrowe<a href="/ja/vhosts/examples.html" hreflang="ja" rel="alternate" title="Japanese"> ja </a> |
14d5b1a7866541c4eb974f2d213d2aea59743c95wrowe<a href="/ko/vhosts/examples.html" hreflang="ko" rel="alternate" title="Korean"> ko </a> |
14d5b1a7866541c4eb974f2d213d2aea59743c95wrowe<a href="/tr/vhosts/examples.html" hreflang="tr" rel="alternate" title="T�rk�e"> tr </a></p>
14d5b1a7866541c4eb974f2d213d2aea59743c95wrowe <p>This document attempts to answer the commonly-asked questions about
14d5b1a7866541c4eb974f2d213d2aea59743c95wrowe setting up <a href="index.html">virtual hosts</a>. These scenarios are those involving multiple
14d5b1a7866541c4eb974f2d213d2aea59743c95wrowe web sites running on a single server, via <a href="name-based.html">name-based</a> or <a href="ip-based.html">IP-based</a> virtual hosts.
14d5b1a7866541c4eb974f2d213d2aea59743c95wrowe<div id="quickview"><ul id="toc"><li><img alt="" src="/images/down.gif" /> <a href="#purename">Running several name-based web
14d5b1a7866541c4eb974f2d213d2aea59743c95wrowe<li><img alt="" src="/images/down.gif" /> <a href="#twoips">Name-based hosts on more than one
14d5b1a7866541c4eb974f2d213d2aea59743c95wrowe<li><img alt="" src="/images/down.gif" /> <a href="#intraextra">Serving the same content on
14d5b1a7866541c4eb974f2d213d2aea59743c95wrowe different IP addresses (such as an internal and external
14d5b1a7866541c4eb974f2d213d2aea59743c95wrowe<li><img alt="" src="/images/down.gif" /> <a href="#port">Running different sites on different
14d5b1a7866541c4eb974f2d213d2aea59743c95wrowe<li><img alt="" src="/images/down.gif" /> <a href="#ip">IP-based virtual hosting</a></li>
14d5b1a7866541c4eb974f2d213d2aea59743c95wrowe<li><img alt="" src="/images/down.gif" /> <a href="#ipport">Mixed port-based and ip-based virtual
14d5b1a7866541c4eb974f2d213d2aea59743c95wrowe<li><img alt="" src="/images/down.gif" /> <a href="#mixed">Mixed name-based and IP-based
14d5b1a7866541c4eb974f2d213d2aea59743c95wrowe<li><img alt="" src="/images/down.gif" /> <a href="#proxy">Using <code>Virtual_host</code> and
14d5b1a7866541c4eb974f2d213d2aea59743c95wrowe<li><img alt="" src="/images/down.gif" /> <a href="#default">Using <code>_default_</code>
14d5b1a7866541c4eb974f2d213d2aea59743c95wrowe<li><img alt="" src="/images/down.gif" /> <a href="#migrate">Migrating a name-based vhost to an
dcf1a2f80f16265f00fe147de1dbd91af9c32a42wrowe<li><img alt="" src="/images/down.gif" /> <a href="#serverpath">Using the <code>ServerPath</code>
14d5b1a7866541c4eb974f2d213d2aea59743c95wrowe<div class="top"><a href="#page-header"><img alt="top" src="/images/up.gif" /></a></div>
14d5b1a7866541c4eb974f2d213d2aea59743c95wrowe<h2><a name="purename" id="purename">Running several name-based web
14d5b1a7866541c4eb974f2d213d2aea59743c95wrowe <p>Your server has a single IP address, and multiple aliases (CNAMES)
14d5b1a7866541c4eb974f2d213d2aea59743c95wrowe point to this machine in DNS. You want to run a web server for
14d5b1a7866541c4eb974f2d213d2aea59743c95wrowe <code>www.example.com</code> and <code>www.example.org</code> on this
14d5b1a7866541c4eb974f2d213d2aea59743c95wrowe machine.</p>
14d5b1a7866541c4eb974f2d213d2aea59743c95wrowe host configurations on your Apache server does not magically
14d5b1a7866541c4eb974f2d213d2aea59743c95wrowe cause DNS entries to be created for those host names. You
14d5b1a7866541c4eb974f2d213d2aea59743c95wrowe <em>must</em> have the names in DNS, resolving to your IP
0bcc003d275c6b0a9060d43be89762b218cbc2c7wrowe address, or nobody else will be able to see your web site. You
14d5b1a7866541c4eb974f2d213d2aea59743c95wrowe can put entries in your <code>hosts</code> file for local
14d5b1a7866541c4eb974f2d213d2aea59743c95wrowe testing, but that will work only from the machine with those
14d5b1a7866541c4eb974f2d213d2aea59743c95wrowe <div class="example"><h3>Server configuration</h3><p><code>
dcf1a2f80f16265f00fe147de1dbd91af9c32a42wrowe # Ensure that Apache listens on port 80<br />
dcf1a2f80f16265f00fe147de1dbd91af9c32a42wrowe Listen 80<br />
14d5b1a7866541c4eb974f2d213d2aea59743c95wrowe <VirtualHost *:80><br />
14d5b1a7866541c4eb974f2d213d2aea59743c95wrowe # Other directives here<br />
14d5b1a7866541c4eb974f2d213d2aea59743c95wrowe </VirtualHost><br />
14d5b1a7866541c4eb974f2d213d2aea59743c95wrowe <VirtualHost *:80><br />
at <code>192.168.111.2</code>. The <code class="directive"><a href="/mod/mod_proxy.html#proxypreservehost on">ProxyPreserveHost On</a></code> directive is
<p>You can use <code class="directive"><a href="/mod/mod_alias.html#aliasmatch">AliasMatch</a></code> or
<code class="directive"><a href="/mod/mod_rewrite.html#rewriterule">RewriteRule</a></code> to rewrite any
<code>www.example.org</code> (from our <a href="#name">name-based</a> example, setup 2) should get its own IP
<p>The <code class="directive"><a href="/mod/mod_rewrite.html#rewriterule">RewriteRule</a></code> directives
<p><span>Available Languages: </span><a href="/en/vhosts/examples.html" title="English"> en </a> |
<a href="/fr/vhosts/examples.html" hreflang="fr" rel="alternate" title="Fran�ais"> fr </a> |
<a href="/ja/vhosts/examples.html" hreflang="ja" rel="alternate" title="Japanese"> ja </a> |
<a href="/ko/vhosts/examples.html" hreflang="ko" rel="alternate" title="Korean"> ko </a> |
<a href="/tr/vhosts/examples.html" hreflang="tr" rel="alternate" title="T�rk�e"> tr </a></p>
<p class="apache">Copyright 2011 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="/faq/">FAQ</a> | <a href="/glossary.html">Glossary</a> | <a href="/sitemap.html">Sitemap</a></p></div>