?
Solved

forwarding cname to vhost

Posted on 2008-10-08
3
Medium Priority
?
666 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 20

Accepted Solution

by:
edster9999 earned 2000 total points
ID: 22669050
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
ID: 22675436
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
ID: 22675513
yep i figured that after I posted this :) thanks anyway for the spot on answer :)
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have a multi-homed DNS setup in windows, you can have issues with connectivity to the server that hosts the DNS services (or even member servers of your domain if this same DNS server is a DC). This is because windows registers all of its IPs…
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

752 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