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.
Just to add a bit of clarity, the first of these entries "owns" the :8080 port, and so the second one is ignored.
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.Insert a
NameVirtualHost *:8080
directive and try again.