1

I am hosting multiple websites on an instance of OS X Server 4.0 with an issue. I have a default personal site that is available on the normal domain and the www subdomain. I tried to configure other sites to have that similar result also. However, I am running into a problem. My virtual hosts (other sites) have the www subdomain configured in the DNS records. I configured my Virtual Hosts in OS X Server with 0 additional domains, redirects, or aliases. All other settings are also left default.

The DNS on OS X Server is configured correctly as well. When I try to access http://example.com/ it sends me to the Virtual Host correctly. However, when I do http://www.example.com/ it sends me to the Server Default website, which is my personal site. The only way I can fix this is to add another website using the www.example.com into the list.

Is there another way to fix this instead of adding another site to the list?

Jenny D
  • 27,780
  • 21
  • 75
  • 114
Felix Jen
  • 403
  • 5
  • 18

2 Answers2

1

Add www.example.com as a ServerAlias to the VirtualHost you want it to use.

Jenny D
  • 27,780
  • 21
  • 75
  • 114
  • Thank you so much! That was the answer I was looking for! Is there a built in setting on OS X Server for that option, instead of directly editing Apache config files? – Felix Jen Mar 25 '15 at 05:17
1

Edit httpd.conf to read;

<VirtualHost *:80(443?)>
    ServerName example.com
    ServerAlias www.example.com
    DocumentRoot /your/doc/root/
</VirtualHost> 

Another little nifty trick for ServerAlias that i like is;

ServerAlias *.example.com

(gibberish.example.com@192.168.0.1:80), will still be go to example.com

Snow
  • 30
  • 1
  • 4