Bluehost.com Web Hosting $6.95

Apache 2.0 Virtual Hosts

This is a discussion on Apache 2.0 Virtual Hosts within the Linux Web Servers forums, part of the Web Server and Related Forums category; OK.. can't seem to get Virtual Hosts to work.. All requests are going to the first listed "VirtualHost&...


Go Back   Usenet Forums > Web Server and Related Forums > Linux Web Servers

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 07-17-2003
Todd
 
Posts: n/a
Default Apache 2.0 Virtual Hosts

OK.. can't seem to get Virtual Hosts to work.. All requests are going
to the first listed "VirtualHost" no matter what domain is requested.

httpd.conf file excerpts below...
__________________________________________
Listen 80
DocumentRoot "/var/www/html/"
#
# Use name-based virtual hosting.
#
NameVirtualHost *:80
# Virtual host domain1.com
<VirtualHost *>
DocumentRoot /var/www/html/domain1
ServerName www.domain1.com
</VirtualHost>
<VirtualHost *>
DocumentRoot /var/www/html/domain1/domain2
ServerName www.domain2.com
</VirtualHost>
___________________________________________

no matter what you request (domain1.com OR domain2.com) it'll always
go to domain1.com. If I reverse the order of the two sections (i.e.
put domain2.com above domain1.com) then all requests go to domain2.com

Am I missing something easy here?? Please help!
  #2 (permalink)  
Old 07-17-2003
The Other Guy
 
Posts: n/a
Default Re: Apache 2.0 Virtual Hosts

On 16 Jul 2003 20:00:46 -0700, The Other Guy responded to a post from
todd91x@hotmail.com (Todd) who wrote in
comp.infosystems.www.servers.unix:

>OK.. can't seem to get Virtual Hosts to work.. All requests are going
>to the first listed "VirtualHost" no matter what domain is requested.
>
>httpd.conf file excerpts below...
>__________________________________________
>Listen 80
>DocumentRoot "/var/www/html/"
>#
># Use name-based virtual hosting.
>#
>NameVirtualHost *:80
># Virtual host domain1.com
><VirtualHost *>
> DocumentRoot /var/www/html/domain1
> ServerName www.domain1.com
></VirtualHost>
><VirtualHost *>
> DocumentRoot /var/www/html/domain1/domain2
> ServerName www.domain2.com
></VirtualHost>
>___________________________________________
>
>no matter what you request (domain1.com OR domain2.com) it'll always
>go to domain1.com. If I reverse the order of the two sections (i.e.
>put domain2.com above domain1.com) then all requests go to domain2.com
>
>Am I missing something easy here?? Please help!


Try using the ServerAlias Directive:
http://httpd.apache.org/docs-2.0/mod...ml#serveralias

<VirtualHost *>
DocumentRoot /var/www/html/domain1
ServerName www.domain1.com
ServerAlias doamain1.com
</VirtualHost>
<VirtualHost *>
DocumentRoot /var/www/html/domain1/domain2
ServerName www.domain2.com
ServerAlias domain2.com
</VirtualHost>

cf. http://httpd.apache.org/docs-2.0/vhosts/name-based.html
http://httpd.apache.org/docs-2.0/vhosts/

HTH
TOG

--
../configure --prefix=~/zyterion
Not this guy or that guy, The Other Guy.

This spot may contain a satirical comment or comedic source,
and is meant to be funny. If you are easily offended, gullible
or don't have a sense of humour we suggest you read elsewhere.
  #3 (permalink)  
Old 07-17-2003
Todd
 
Posts: n/a
Default Re: Apache 2.0 Virtual Hosts

The Other Guy <nospam@this.addy> wrote in message news:<016chvko9tveorfk3tt6las3hjfpkkiclt@4ax.com>. ..
> On 16 Jul 2003 20:00:46 -0700, The Other Guy responded to a post from
> todd91x@hotmail.com (Todd) who wrote in
> comp.infosystems.www.servers.unix:
>
> >OK.. can't seem to get Virtual Hosts to work.. All requests are going
> >to the first listed "VirtualHost" no matter what domain is requested.
> >
> >httpd.conf file excerpts below...
> >__________________________________________
> >Listen 80
> >DocumentRoot "/var/www/html/"
> >#
> ># Use name-based virtual hosting.
> >#
> >NameVirtualHost *:80
> ># Virtual host domain1.com
> ><VirtualHost *>
> > DocumentRoot /var/www/html/domain1
> > ServerName www.domain1.com
> ></VirtualHost>
> ><VirtualHost *>
> > DocumentRoot /var/www/html/domain1/domain2
> > ServerName www.domain2.com
> ></VirtualHost>
> >___________________________________________
> >
> >no matter what you request (domain1.com OR domain2.com) it'll always
> >go to domain1.com. If I reverse the order of the two sections (i.e.
> >put domain2.com above domain1.com) then all requests go to domain2.com
> >
> >Am I missing something easy here?? Please help!

>
> Try using the ServerAlias Directive:
> http://httpd.apache.org/docs-2.0/mod...ml#serveralias
>
> <VirtualHost *>
> DocumentRoot /var/www/html/domain1
> ServerName www.domain1.com
> ServerAlias doamain1.com
> </VirtualHost>
> <VirtualHost *>
> DocumentRoot /var/www/html/domain1/domain2
> ServerName www.domain2.com
> ServerAlias domain2.com
> </VirtualHost>
>
> cf. http://httpd.apache.org/docs-2.0/vhosts/name-based.html
> http://httpd.apache.org/docs-2.0/vhosts/
>
> HTH
> TOG


Thanks TOG... but that's still producing the same results. This is
really killing me.. I've looked through all the docs and my Virtual
Hosts section is exactly what the docs say it should be. The only
thing I can think of is maybe there's a different part that's wrong?
But it all looks the same as well...

I've seen posts from various people here who have the
"NameVirtualHost" look like mine: NameVirtualHost *:80 ... but I've
also seen: NameVirtualHost *

For me.. the later produces an error "Bad Request" no matter what
domain is requested. So it "works" with the :80... but won't go past
the 1st virtual host.
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 12:58 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0