Problem with Apache and Virtual Hosts

I have a question about virtual hosting with Apache/FreeBSD. My site has a single IP, and I'd like to host two separate websites on this IP. Here's the relevant section in httpd.conf:
Code:
<VirtualHost *:80>
ServerName http://www.planetfox.net
ServerAlias planetfox.net
DocumentRoot "/usr/home/webmaster/planetfox"
</VirtualHost>

<VirtualHost *:80>
ServerName http://www.revenstar.net
ServerAlias revenstar.net
DocumentRoot "/usr/home/webmaster/revenstar"
</VirtualHost>
Whichever one is listed first is served, no matter which URL is entered. Is a local nameserver required for this to work?
 
Add a NameVirtualHost directive before the actual virtual host containers, and remove the http:// scheme from the ServerName directives.

Code:
NameVirtualHost *:80

<VirtualHost *:80>
   ServerName www.planetfox.net:80
   ServerAlias planetfox.net
   DocumentRoot "/usr/home/webmaster/planetfox"
</VirtualHost>

<VirtualHost *:80>
   ServerName www.revenstar.net:80
   ServerAlias revenstar.net
   DocumentRoot "/usr/home/webmaster/revenstar"
</VirtualHost>
You need to restart apache after the changes.
 
Back
Top