0

I have XAMPP installed for local development and I'd like to create a sub domain for each project. In my apache vhosts config I've put this:

<VirtualHost localhost:80>
DocumentRoot C:/xampp/htdocs/
ServerName localhost
ServerAdmin admin@localhost
</VirtualHost>

<VirtualHost nexus.localhost:80>
DocumentRoot C:/xampp/htdocs/nexus/
ServerName nexus.localhost
ServerAdmin admin@nexus.localhost
</VirtualHost>

And in my Windows hosts file:

# development
127.0.0.1 localhost
127.0.0.1 nexus.localhost

localhost works as normal. As in, if I go to http://localhost/project_name everything works fine. However, if I navigate to http://nexus.localhost/ I just get Object not found! errors.

What could be wrong here? Thank you.

James Dawson
  • 5,309
  • 20
  • 72
  • 126

1 Answers1

0

The documentation http://httpd.apache.org/docs/2.2/mod/core.html#virtualhost says that the <VirtualHost> directive should contain the IP address, so try this instead:

<VirtualHost 127.0.0.1:80>
DocumentRoot C:/xampp/htdocs/
ServerName localhost
ServerAdmin admin@localhost
</VirtualHost>

<VirtualHost 127.0.0.1:80>
DocumentRoot C:/xampp/htdocs/nexus/
ServerName nexus.localhost
ServerAdmin admin@nexus.localhost
</VirtualHost>
Tchoupi
  • 14,560
  • 5
  • 37
  • 71
  • That's better, however both VirtualHosts seem to point to the same document root. For example, if I go to `http://nexus.localhost/`, it shows the root directory, not `/nexus`. – James Dawson May 18 '12 at 21:03
  • @MartinHoe Do you have a `NameVirtualHost 127.0.0.1` line? (http://sawmac.com/xampp/virtualhosts/) – Tchoupi May 19 '12 at 16:10