Have you added the NameVirtualHost
directive before the vhosts declaration ?
NameVirtualHost *:80
<VirtualHost *:80>
...
</VirtualHost>
Вопрос
On my webserver, I want to serve several websites just based on domain name.
For example, I want a webserver that will serve "mycoolsite.com" and "badstuff.org".
I pointed both sites at the same IP address. In httpd-vhosts, I made two entries:
<VirtualHost *:80>
DocumentRoot /www/mycoolsite
ServerName www.mycoolsite.com
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /www/badstuff
ServerName www.badstuff.org
</VirtualHost>
But when I go to badstuff.org, I get served mycoolsite.com! Why is this happening?
I also know that when I use MAMP, I have to adjust my "hosts" file too. Is this relevant?
Решение
Have you added the NameVirtualHost
directive before the vhosts declaration ?
NameVirtualHost *:80
<VirtualHost *:80>
...
</VirtualHost>
Другие советы
You may want to check your configuration by command:
$/usr/local/apache2/bin/httpd -S
If everything is OK, try to check again by restarting the server.