Second domain resolves to the first

Problems with the Windows version of XAMPP, questions, comments, and anything related.

Second domain resolves to the first

Postby Duncan » 09. April 2009 20:17

Have searched but I didn't find the issue. Perhaps something to do with my terminology. Apologies if this is answered elsewhere.

I use XAMPP for local development work. I've had my first virtual domain working well for some time and just decided to add a second. However, when I try to navigate to the second in my browser, it resolves to the first one I set up. When I change the order of my virtual hosts in my httpd-vhosts.conf file then the second domain comes up great, but the first then resolves to the second. :?

The entries from httpd-vhosts.conf are shown below. Can anyone please tell me where I'm going wrong please? Doubtless it will be down to my idiocy but all help gratefully received.

Code: Select all
NameVirtualHost *:80
  <VirtualHost *:80>
    DocumentRoot "C:/xampp/htdocs"
    ServerName localhost
  </VirtualHost>

 
  <VirtualHost dev.lifeofpi.co.uk>
    DocumentRoot "C:/xampp/htdocs/lifeofpi.co.uk"
    ServerName dev.lifeofpi.co.uk
  <Directory "C:/xampp/htdocs/lifeofpi.co.uk/">
    Order allow,deny
    Allow from all
  </Directory>
</VirtualHost>

  <VirtualHost dev.cafesejuiced.com>
    DocumentRoot "C:/xampp/htdocs/cafesejuiced.com"
    ServerName dev.cafesejuiced.com
  <Directory "C:/xampp/htdocs/cafesejuiced.com/">
    Order allow,deny
    Allow from all
  </Directory>
</VirtualHost>


Also have my Windows hosts file but I don't think that's the problem.
Code: Select all
# Copyright (c) 1993-1999 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
#      102.54.94.97     rhino.acme.com          # source server
#       38.25.63.10     x.acme.com              # x client host

127.0.0.1       localhost
127.0.0.1 dev.lifeofpi.co.uk
127.0.0.1 dev.cafesejuiced.com
Duncan
 
Posts: 2
Joined: 09. April 2009 20:03

Re: Second domain resolves to the first

Postby Sharley » 09. April 2009 23:27

Your VirtualHost should be the same as the NameVirtualHost - *:80
No trailing slash in the Directory directive.
Code: Select all
NameVirtualHost *:80
  <VirtualHost *:80>
    DocumentRoot "C:/xampp/htdocs"
    ServerName localhost
  </VirtualHost>

 
  <VirtualHost *:80>
    ServerName dev.lifeofpi.co.uk
    DocumentRoot "C:/xampp/htdocs/lifeofpi.co.uk"
  <Directory "C:/xampp/htdocs/lifeofpi.co.uk">
    Options Indexes FollowSymLinks Includes ExecCGI
    Order allow,deny
    Allow from all
  </Directory>
</VirtualHost>

  <VirtualHost *:80>
    ServerName dev.cafesejuiced.com
    DocumentRoot "C:/xampp/htdocs/cafesejuiced.com"
  <Directory "C:/xampp/htdocs/cafesejuiced.com">
    Options Indexes FollowSymLinks Includes ExecCGI
    Order allow,deny
    Allow from all
  </Directory>
</VirtualHost>
I added the Options directive as these are helpful and may be of use latter on in development and will do no harm if used at this stage.


Please see how that goes now and kindly let us know back if it helped.
Thanks.
User avatar
Sharley
AF Moderator
 
Posts: 3316
Joined: 03. October 2008 05:10
Location: Yeppoon, Australia Time Zone: GMT/UTC+10
Operating System: Win 7 Pro 32bit/XP Pro SP3

Re: Second domain resolves to the first

Postby Duncan » 10. April 2009 13:45

Thank you Sharley, that worked like a charm. Thank you for taking the time to help, much appreciated. :)
Duncan
 
Posts: 2
Joined: 09. April 2009 20:03


Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 63 guests