0

This is my vhosts.conf

<VirtualHost *:80>
DocumentRoot "C:/wamp/www"
ServerName localhost
</VirtualHost>

<VirtualHost *:80>
DocumentRoot "C:/wamp/www/images"
ServerName images.localhost
</VirtualHost>

<VirtualHost *:80>
DocumentRoot "C:/wamp/www/project"
ServerName project.localhost
</VirtualHost>

Listen 8080
<VirtualHost *:8080>
DocumentRoot "C:/wamp/www/trunk"
ServerName localhost
</VirtualHost>

<VirtualHost *:8080>
DocumentRoot "C:/wamp/www/images2"
ServerName images2.localhost
</VirtualHost>

and this is my windows host file

127.0.0.1 project.localhost 

127.0.0.1 images.localhost

127.0.0.1 images2.localhost

So the first three are fine. The localhost on port 8080 works, I just go to localhost:8080 and it loads what's inside trunk.

The images2.localhost:8080 shows what's inside C:/wamp/www/trunk and images2.localhost just goes to the wampserver main page. Tried changing to this but it's still the same.

2 Answers 2

5

Just to add a bit of clarity, the first of these entries "owns" the :8080 port, and so the second one is ignored.

<VirtualHost *:8080>
DocumentRoot "C:/wamp/www/trunk"
ServerName localhost
</VirtualHost>

<VirtualHost *:8080>
DocumentRoot "C:/wamp/www/images2"
ServerName images2.localhost
</VirtualHost>

What you want is name based virtual servers, so you can make the first and second entries unique. This is what makes the ServerName directive actually do something. As stated by @quanta, add NameVirtualHost *:8080 to the configuration, and then Apache will pay attention to the url you type in the browser and serve the pages based on the ServerName directive that matches the URL.

1

Insert a NameVirtualHost *:8080 directive and try again.

2
  • 1
    Your call could not be connected, please check the number and try again...
    – Silverfire
    Sep 30, 2011 at 6:51
  • 1
    What are you talking about?
    – quanta
    Sep 30, 2011 at 6:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .