I have a problem with ServerAliases not resolving to the corresponding server.
My hosts file is set up as such (this is part of trying to set up APE so please excuse the extraneous code):
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost
127.0.0.1 testy.local
127.0.0.1 testsite.local
127.0.0.1 ape-test.local
127.0.0.1 chickens.cluck.com
127.0.0.1 ape.ape-test.local
127.0.0.1 ape2.ape-test.local
And the httpd-vhosts.conf:
NameVirtualHost *:80
<VirtualHost *:80>
ServerName ape-test.local
ServerAlias ape.ape-test.local
ServerAlias test.ape-test.local
ServerAlias *.ape.ape-test.local
DocumentRoot "/Library/WebServer/Documents/"
</VirtualHost>
<VirtualHost *:80>
ServerName testy.local
ServerAlias testy
ServerAlias fish.local
DocumentRoot "/Users/myusername/Sites/testsite"
<Directory /Users/myusername/Sites/testsite/>
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Virtual hosts have been enabled in httpd.conf, and testy.local resolves to the correct directory. But using ‘testy/’ or ‘fish.local’ will not resolve.
There appears to be nothing written to the error log or console either, and running sudo bash -x /usr/sbin/apachectl -k start reveals no errors.
Running httpd -S reveals no problems either:
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:80 is a NameVirtualHost
default server ape-test.local (/private/etc/apache2/extra/httpd-vhosts.conf:44)
port 80 namevhost ape-test.local (/private/etc/apache2/extra/httpd-vhosts.conf:44)
port 80 namevhost testy.local (/private/etc/apache2/extra/httpd-vhosts.conf:53)
Syntax OK
So it appears as just the ServerAlias isn’t working.
Does anybody have any ideas?
By looking at your host file, it doesn’t seem you provided ‘testy’ or ‘fish.local’ in your host file. You just need to enter both of these domains in your host file and you should be all set then.
You need to add them as I did below,
Hope this helps.