How do I get my Apache virtual hosts working?

I'm trying to set up virtual hosts for local development and can't seem to get it working.

I have this in my httpd.conf:

NameVirtualHost *

<VirtualHost *>
 ServerName localhost
 DocumentRoot C:/Users/Elliot/dev/UniServer/www
</VirtualHost>

<VirtualHost *>
 ServerName drupal.dev
 DocumentRoot C:/Users/Elliot/dev/UniServer/www/drupal.dev/httpdocs
</VirtualHost>

and this in C:\Windows\System32\drivers\etc\hosts:

127.0.0.1       localhost
127.0.0.1       drupal.dev

http://localhost resolves OK, http://drupal.dev/ does not.

Any ideas welcomed...


Edit: I'm pretty sure that my hosts file is the underlying problem and that any edits are being ignored.

Oddly, I can edit, save and delete it without elevated permissions, which should not be the case on Windows >= Vista.

Am working through 'What can cause a DNS lookup to ignore a hosts file entry?', 'HOSTS file being ignored' and 'Problem with the hosts file in Windows XP (as a new user I can't post links).


Edit: in my case, stopping the DNS Client service resolved the issue....


Edit: ...but only very briefly.


Solution 1:

Look at the example here:

http://www.cyberciti.biz/faq/apache-name-based-virtualhost-example/

Set the IP address for the NameVirtualHost and then replace the * for each VirtualHost with the qualified name (localhost for the first and drupal.dev for the second).

Solution 2:

Try putting drupal.dev on the same line as localhost in your hosts file, e.g:

127.0.0.1   localhost drupal.dev