Solved

forwarding cname to vhost

Posted on 2008-10-08
3
656 Views
Last Modified: 2012-05-05
I have vhost setup one tld and a sub domain (since they are in different directories).
ex.
<VirtualHost *:80>
    ServerAdmin webmaster@domain.com
    DocumentRoot /var/www/html
    ServerName www.domain.com
    ErrorLog /var/log/httpd/www.domain.com-error_log
    CustomLog /var/log/httpd/www.domain.com-access_log common
</VirtualHost>
<VirtualHost *:80>
    ServerAdmin webmaster@domain.com
    DocumentRoot /var/www/sub/html
    ServerName sub.domain.com
    ErrorLog /var/log/httpd/sub.domain.com-error_log
    CustomLog /var/log/httpd/sub.domain.com-access_log common
</VirtualHost>

when i use a cname "test.differentdomain.com" to pint to sub.domain.com, the request takes me domain.com ????? can someone help me ?
0
Comment
Question by:shadow2007
3 Comments
 
LVL 20

Accepted Solution

by:
edster9999 earned 500 total points
Comment Utility
The first doamin listed is the default one so if you go to www.anything.com and that redirects via a cname or a address to your server but it is not listed it will go into the first one.

add a serveralias to the second one to catch it....

ServerAlias test.differentdomain.com

or even

ServerAlias *.differentdomain.com, differentdomain.com

The *. will miss it if they do not specify a subdomain so you would need this if they only went to http://differentdomain.com

so the config will now look like this :

<VirtualHost *:80>
    ServerAdmin webmaster@domain.com
    DocumentRoot /var/www/html
    ServerName www.domain.com
    ErrorLog /var/log/httpd/www.domain.com-error_log
    CustomLog /var/log/httpd/www.domain.com-access_log common
</VirtualHost>
<VirtualHost *:80>
    ServerAdmin webmaster@domain.com
    DocumentRoot /var/www/sub/html
    ServerName sub.domain.com
    ServerAlias *.differentdomain.com, differentdomain.com
    ErrorLog /var/log/httpd/sub.domain.com-error_log
    CustomLog /var/log/httpd/sub.domain.com-access_log common
</VirtualHost>

0
 
LVL 4

Expert Comment

by:urgoll
Comment Utility
You also need to specify :

NameVirtualHost *:80

This is a required statement that enables name-based virtualhosting.

Please refer to Apache's documentation:
http://httpd.apache.org/docs/2.0/mod/core.html#namevirtualhost
0
 

Author Comment

by:shadow2007
Comment Utility
yep i figured that after I posted this :) thanks anyway for the spot on answer :)
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Join & Write a Comment

I wrote this article to explain some important DNS concepts that should be known to avoid some typical configuration errors I often see in forums. I assume that what is described here is the typical behavior of Microsoft DNS client. I don't know …
It is possible to boost certain documents at query time in Solr. Query time boosting can be a powerful resource for finding the most relevant and "best" content. Of course the more information you index, the more fields you will be able to use for y…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now