Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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.

share|improve this question

2 Answers 2

up vote 5 down vote accepted

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.

share|improve this answer

Insert a NameVirtualHost *:8080 directive and try again.

share|improve this answer
1  
Your call could not be connected, please check the number and try again... –  Silverfire Sep 30 '11 at 6:51
1  
What are you talking about? –  quanta Sep 30 '11 at 6:54

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.