0

Server Environment: Ubuntu 12.04 | Apache 2.2

I have disabled the default vhost configuration using a2dissite default and deleted the default file from sites-available and sites-enabled. I have 3 domains pointed at the VPS at DigitalOcean and I've added CNAME records for www linked to domain.com. (with the trailing dot).

Theis is the current setup:

Navigating to domain1.com serves the intended DocumentRoot, so does domain2.com. However, navigating to www.domain1.com serves the DocumentRoot of domain2.com (this is the problem). This doesn't seem to happen with www.domain2.com which serves the correct path. domain3.com which has no vhost created also mysteriously serves the content from domain2.com

If I delete the www CNAME records, the links with www do not work after DNS propagation. I have seen suggestions to add a ServerAlias directive in the vhost files. When I add such directives, Apache errors out with the following:

"ScriptAlias takes two arguments, a fakename and a realname"

How can I solve this problem?

11
  • I have not entered the actual domain names here to avoid bots picking them up, but they are available at the pastie.org links above. You can try accessing the server yourself to understand the situation better. Thanks! Commented Aug 9, 2014 at 12:33
  • Hi there, Can you include your httpd.conf and vhosts.conf if you have one? Commented Aug 9, 2014 at 12:36
  • @krisFR, I'm guessing the links in your post will get indexed. Care to mask them with arc.com.ng instead. Yes, arc.com.ng and the www equivalent works, but www .hrsys.com.ng (actual domain masked) points to arc's DocumentRoot. Do you understand me? Commented Aug 9, 2014 at 12:43
  • @DavidEisen I checked under /etc/apache2/ - the httpd.conf file there is empty (0 bytes). Commented Aug 9, 2014 at 12:44
  • Ok sorry, made a mistake. What if you replace <VirtualHost *:80> by <VirtualHost xx.xx.xx.xx:80> (where xx is the ip address) for each domain ? Commented Aug 9, 2014 at 12:50

1 Answer 1

0

Not sure why you get this error when using ServerAlias, however this should be the way to go.

From the docmuentation :

The ServerAlias directive sets the alternate names for a host, for use with name-based virtual hosts

This is actually what you are doing, as you have defined www.hrsys.com.ng as an alias (CNAME) in your DNS for hrsys.com.ng.

2
  • Thank you for your answer. The ServerAlias eventually worked, however I had to create a CNAME record for WWW pointing to mydomain.com. (with the trailing dot). Commented Aug 9, 2014 at 16:13
  • Of course you had to do so, this is what my last sentence says, but i edit to be more clear ;) Commented Aug 9, 2014 at 16:15

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.