Forum Moderators: phranque

Message Too Old, No Replies

Newbie Apache Virtual Hosting Problems

second site showing first site contents

         

wencooley

9:51 pm on Feb 17, 2009 (gmt 0)

10+ Year Member



I have installed Apache2 on a Vista machine. The original site works like it suppose to so I decided to add another site to host. It took me a while but I finally got to where I could put in www.thesite.com in a browser and it would connect but it brings up the original's pages. Can someone give me a hand with this issue? Thanks

jdMorgan

12:36 am on Feb 18, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The answer depends on how you configured the two VirtualHosts [httpd.apache.org].

Jim

[edited by: jdMorgan at 12:38 am (utc) on Feb. 18, 2009]

wencooley

1:49 am on Feb 18, 2009 (gmt 0)

10+ Year Member



Here is basically how I have my virtual hosts setup.

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 #*$!.#*$!.#*$!.#*$!:80>
ServerAdmin wencooley@example.com
DocumentRoot "C:/website/site1.com"
ServerName site1.com
ServerAlias www.site1example.com webserver.ftpexample.com
ErrorLog "logs/site1.com-error.log"
CustomLog "logs/site1.com-access.log" common
AddHandler server-parsed .shtml
Options FollowSymLinks +Includes
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
</VirtualHost>

<VirtualHost site2.bounceme.net>
ServerAdmin wencooley@example.com
DocumentRoot "C:/website/site2.com"
ServerName site2.com
ErrorLog "logs/site2.com-error.log"
CustomLog "logs/site2.com-access.log" common
AddHandler server-parsed .shtml
Options FollowSymLinks +Includes
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
</VirtualHost>

[edited by: jdMorgan at 2:07 am (utc) on Feb. 18, 2009]
[edit reason] example.com [/edit]

jdMorgan

2:16 am on Feb 18, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Your second site will likely be served by the first vhost container because the IP address matches. It may therefore be treated as an "IP-based virtual host" and the name-based parameters won't be required or used -- See the Apache docs linked above.

Try reversing the two <VirtualHost> containers, or give your first one a domain name instead of using the IP address.

The answer might be simpler, but I'm assuming that the host/servername discrepancies in your second vHost container are just accidental results of obscuring the real names for posting here. Be aware that a request will be served by the first vHost container that matches the hostname sent by the client, and that if none match, the first vHost container will be used as the "default".

Jim