Forum Moderators: phranque
I'm running windows 2000 with apache 2. I need to configure the server to host two web sites. I have setup the virtual hosts and it works fine when I try to access the two sites on the server. But when I try to access the second site over the internet all I get is the first site.
I have set the two domains up to point to the same IP address. Should I forward them onto a certain page i.e.
Thanks
Have you had a look through the Apache Virtual Host documentation [httpd.apache.org] yet? There are examples in there that should get you over the hump. Pay special attention to the Listen directives and Name based vs. IP based hosting and look through the examples.
I have two options on the web forwarding, either framed or non-framed. The non-framed leaves the ip address of my server in the title bar and the framed replaces the ip address with the domain name.
I have set the two domains up to use framed forwarding
www.site1.co.uk >> [x.x.x.x...]
www.site2.co.uk >> [x.x.x.x...]
If go to another machine over the internet and enter www.site2.co.uk, it shows www.site2.co.uk in the browser but it actually displays site1's web site.
Again if I try this on the server itself it works fine, so it must be how the request is coming in to the server over the internet.
This is how my httpd.conf is setup
NameVirtualHost *:80
<VirtualHost *:80>
ServerName www.site1.co.uk
ServerAlias site1.co.uk *.site1.co.uk
DocumentRoot C:/home/site1
</virtualhost>
<VirtualHost *:80>
ServerName www.site2.co.uk
ServerAlias site2.co.uk *.site2.co.uk
DocumentRoot C:/home/site2
</virtualhost>
Welcome to WebmasterWorld!
A simple solution would be to bypass the "forwarding" and simply point the DNS records for both domains to your IP address. The forwarding function is probably dropping the hostname header from the request, so your server can't see it. Without that header, name-based hosting won't work.
Jim
I have now set the second domain up to point to a folder within the first site.
<VirtualHost *>
ServerName www.site1.co.uk
ServerAlias site1.co.uk *.site1.co.uk
DocumentRoot "C:/home/site1"
</virtualhost>
<VirtualHost *>
ServerName www.site2.co.uk
ServerAlias site2.co.uk *.site2.co.uk
DocumentRoot "C:/home/site1/site2"
</virtualhost>
I then forwarded the two domains as
www.site1.co.uk >> [x.x.x.x...]
www.site2.co.uk >> [x.x.x.x...]
I realise its not using the vistrualhost as such when its coming in over the internet but it will do.
Thanks
Steve