Page 1 of 1

Vhosts not redirecting? All sites going to first block

PostPosted: 10. November 2006 14:58
by coglanuk
Hi folks,

I have been running vhosts for a while (pointlessy as only one site is being hosted), I added a second site last night and the vhsots is working correctly.

Both sites are redirecting to the first site listed in the vhosts file. I have added both site to the hosts file in Windows but still no joy.

Can someone please take a look at my vhosts file.

Code: Select all
#
# Virtual Hosts
#
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:http://httpd.apache.org/docs/2.2/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.

#
# Use name-based virtual hosting.
#
NameVirtualHost *:80

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#

<VirtualHost *>
ServerName www.cbfoodhygiene.co.uk
DocumentRoot "C:\Program Files\xampp\htdocs\cb"
<Directory "C:\Program Files\xampp\htdocs\cb">
IndexOptions +FancyIndexing NameWidth=*
Options Includes FollowSymLinks Indexes
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

<VirtualHost *>
ServerName www.handsonmaintenance.co.uk
DocumentRoot "C:\Program Files\xampp\htdocs\hom"
<Directory "C:\Program Files\xampp\htdocs\hom">
IndexOptions +FancyIndexing NameWidth=*
Options Includes FollowSymLinks Indexes
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
:?:

PostPosted: 10. November 2006 16:15
by Izzy
What does the command apache -S return?

Open a command console in xampp\apache\bin
type apache -S and see if it gives any clues.

NameWidth=* is not on the list of acceptable Options:
http://httpd.apache.org/docs/2.2/mod/core.html#options
Not sure if will have an effect on your problem though.

Also Apache likes the / slash not the \ slash so try swap those over.
"C:\Program Files\xampp\htdocs\cb"
to
"C:/Program Files/xampp/htdocs/cb"
If there are any issues with your httpd-vhosts.conf file then your first container, which is the default, will be the only site that is served as in your case.

PostPosted: 10. November 2006 21:25
by coglanuk
I changed the \ to a / and it had no effect.

I'm preety sure the fault lies in the output of the -S, I just can't uderstand how to resolve it.

PLEASE HELP!

Code: Select all
C:\Program Files\xampp\apache\bin>apache -S
[Fri Nov 10 20:21:53 2006] [warn] NameVirtualHost *:80 has no VirtualHosts
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:*                    www.cbfoodhygiene.co.uk (C:/Program Files/xampp/apache/co
nf/httpd-vhosts.conf:28)
*:*                    www.handsonmaintenance.co.uk (C:/Program Files/xampp/apac
he/conf/httpd-vhosts.conf:40)
_default_:443          localhost (C:/Program Files/xampp/apache/conf/extra/httpd
-ssl.conf:74)
Syntax OK

PostPosted: 11. November 2006 00:39
by Izzy
coglanuk wrote:I'm preety sure the fault lies in the output of the -S, I just can't uderstand how to resolve it.

[warn] NameVirtualHost *:80 has no VirtualHosts

VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:* www.cbfoodhygiene.co.uk (C:/Program Files/xampp/apache/conf/httpd-vhosts.conf:28)


NameVirtualHost *:80
Try changing this :
<VirtualHost *>
to this:
<VirtualHost *:80>

or
NameVirtualHost *:*
change this:
<VirtualHost *>
to this
<VirtualHost *:*>

See if that fixes things up for you.

PostPosted: 11. November 2006 01:14
by coglanuk
NameVirtualHost *:80
Try changing this :
<VirtualHost *>
to this:
<VirtualHost *:80>


Resolved it!!!

Thanks Izzy, your a lifesaver.