-2

*.mydomain.com is pointing to this directory /home/mydirectory so if I enter :

foo.mydomain.com or bar.mydomain.com it points to /home/mydirectory

in another domaine I've set a CNAME as : www.otherdomain. -> foo.mydomain.com.

But www.otherdomain.com points to the web root directory /var/www and note /home/mydirectory

sel_space
  • 107
  • 4

2 Answers2

2

It seems like you are getting a couple of technologies and how they interact confused.

A CNAME is a DNS resource record which points to another DNS RR. This is frequently used to point a hostname to another e.g.

www.otherdomain.com.        CNAME  foo.mydomain.com.
foo.mydomain.com.           A      192.0.2.23

When someone enters the www.otherdomain.com into their browser the DNS resolver will provide the address 192.0.2.23.

When the browser contacts the server at 192.0.2.23:80 part of the information it provides is a http host header which in your case would be

Host: www.otherdomain.com

This host header is used internally by apache to determine what it should serve. Apache will attempt to match the name in the host header against it's list of ServerName and ServerAlias.

The list of ServerName and SeverAlias are checked in the order they are defined in your configuration files. The contents of the first vhost ServerName or ServerAlias that match is served.

If no match is found then the contents of the first vhost defined are served as this is considered to be the default vhost.

It's not entirely certain what your expectation is but hopefully the information above will help you figure out what the problem is.

user9517
  • 115,471
  • 20
  • 215
  • 297
0

You still need to configure Apache to route requests for the host name. You need to tell it where 'www.otherdomain.com' lives. How would Apache possibly know that you got their via a CNAME to another host?