Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

forwarding cname to vhost

Posted on 2008-10-08
3
Medium Priority
?
670 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 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Hello EE, Today we will learn how to send all your network traffic through Tor which is useful to get around censorship and being tracked all together to a certain degree. This article assumes you will be using Linux, have a minimal knowledge of …
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…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses
Course of the Month9 days, 15 hours left to enroll

926 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