Solved

forwarding cname to vhost

Posted on 2008-10-08
3
662 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
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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Local DNS and Home Routers 4 58
Internal users cannot browse external corporate website 4 30
htaccess - disable PHP in specific directory 1 22
PTR DNS record question 1 31
One of the most often confused topics in the area DNS is the idea of GLUE records. Specifically, what they are, when they are needed, when they are provided, and how they are created. First, WHAT IS GLUE? To understand GLUE, you must first under…
If you've heard about htaccess and it sounds like it does what you want, but you're not sure how it works... well, you're in the right place. Read on. Some Basics #1. It's a file and its filename is .htaccess (yes, with a dot in the front). #…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

730 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