Reputation: 1
I can't get Apache's configuration to return the correct page, if there is a hyphen in the ServerName. I found a page here titled, "Dashes not allowed in virtual host entry?", but it was dealing with hyphens in the DocumentRoot, not with ServerName. In any case, it did not solve my problem, and I've been unable to find any other references to this problem.
I'm setting up multiple virtual hosts (VH) on a recently acquired Ubuntu 12.04 server, running Apache. Ubuntu's configuration for this is organized so that you have folders for sites-available and sites-enabled. A separate file, placed in sites-availabe is used for each individual VH. Enabling the VH is just a matter of making a symlink from the file in the sites-available folder to the sites-enabled folder, and restarting Apache.
I have several working VHs already. It's an easy recipe, since it's just a matter of copying a working file to a new filename, and changing a few variables.
All of my correctly-working entries do NOT have any hyphen in the ServerName, or ServerAlias. The one entry which does have a hyphen, does not work. Instead of returning the proper page, Apache returns the host's base page (which tells me DNS is fine).
I've tried enclosing ServerName and ServerAlias in quotes, with and without. No change.
Lots of domains use hyphens, I can't be the only one with this problem. Has anyone found a workaround? Here's my config:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName datacore-inc.com
ServerAlias www.datacore-inc.com
DocumentRoot /home/web/datacore/www
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /home/web/datacore/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
Upvotes: 0
Views: 2202
Reputation: 53
I had the same issue and thought the problem came from the hyphen character in the ServerName. But actually I had declared the VirtualHost twice. I've removed one of them and that resolved the problem.
Upvotes: 1