On Fri, Aug 15, 2003 at 07:34:48PM -0500, Michael Viron wrote:
> >I use apache on my local host and got mixed results using the *

> 
> If you put the *.example.com entry before any of the other "VirtualHost"
> directives, when something comes in for dev.example.com, apache uses
> whatever the first match is.  In the example above, it would correctly pull
> it from /home/web/test .  On the other hand if *.example.com is before the
> entry (either first or second on the list), it would match that entry and
> incorrectly use the page from /home/web/www, instead of the correct
> /home/web/test -- essentially ignoring any further entries.
> 
> Hope this gives everyone (especially those wanting to set up virtualhosts)
> something useful to work with,
> 
Thanks Michael. Sometimes I find apache configuration very fickle it
takes a lot of trial and error:-( And I've got alot of trial to go :-)

Here's one of them...

Using only a * in the Virtualhost directive. I guess it's advantage
would be less typing in the configuration file.
i.e. <Virtualhost *>

I use apache (2) for testing on my localhost. I've got a half a dozen local
virtual hosts defined in /etc/httpd/conf/vhosts/Vhosts.conf. Each
virtualhost is defined like so <Virtualhost mytestwebsite>. Plus
there is a corresponding host entry in the /etc/hosts file
 "127.0.0.1          mytestwebsite" for local domain name lookup.
All virtual hosts are accessible this way from my local browser
i.e. http://mytestwebsite/. At the top of the Vhosts.conf there is:
NameVirtualHost 127.0.0.1 to tell apache which ip.
Everything works.

But...When I put a * inplace of "mytestwebsite" for all my half dozen
virtual hosts things do go so well. I only get the first listed virtual host :-( 

Following the example in
http://httpd.apache.org/docs-2.0/vhosts/name-based.html
(thank you "HaywireMac") for name-based virtual hosts, it should
work. (I think :-))

I am thinking apache first finds my ip (localhost) then looks at the *
in the <Virutalhost *> then looks inside to see if "ServerName
mytestwebsite" is the same as the requested domain. If they match,
then apache uses that Virtual host. 

I am using the same host name in the /etc/hosts file as in the
VirtualHost directive i.e. "ServerName mytestsite". Translation: The
calling domain name (http://mytestwebsite/) is the same as the ServerName
directive as in the /etc/hosts file. 

Here's a snip from the apache manual... 
<snip>
Now when a request arrives, the server will first check if it is using
an IP address that matches the NameVirtualHost. If it is, then it will
look at each <VirtualHost> section with a matching IP address and try
to find one where the ServerName or ServerAlias matches the requested
hostname. If it finds one, then it uses the configuration for that
server. If no matching virtual host is found, then the first listed
virtual host that matches the IP address will be used.
<snip>

My virtual hosts should match and use the right configuration but all
I get is the first listed virtual host.

I am wondering if me doing all this as localhost would have a
different effect, or I might be missing something somewhere.

Thanks in advance for any light on the subject.

Roland

Want to buy your Pack or Services from MandrakeSoft? 
Go to http://www.mandrakestore.com

Reply via email to