3

I went through lots of SO questions but non is giving me the right answer .

I have following config in apache vhost:

<VirtualHost *:80>
    DocumentRoot "D:/Web Server/xampp/htdocs/testsite/frontend/www"
    ServerName mydomain.com
    ServerAlias www.mydomain.com
</VirtualHost>


<VirtualHost *:80>
    DocumentRoot "D:/Web Server/xampp/htdocs/testsite/backend/www"
    ServerName admin.mydomain.com
    ServerAlias www.admin.mydomain.com
</VirtualHost>

AND hosts file :

127.0.0.1               testsite.com
127.0.0.1               admin.testsite.com

What I need is that:

www.testsite.com and testsite.com should point to same thing

and same with

www.admin.testsite.com and admin.testsite.com

What is the issue with this config ? Do I need to add separate records for each , one with www and other without www ?

please help me sort this issue

thanks in advance

4

2 回答 2

3

You need to add the www. versions of your domains to your etc hosts.

127.0.0.1               testsite.com www.testsite.com
127.0.0.1               admin.testsite.com www.admin.testsite.com
于 2012-11-17T20:48:00.117 回答
1

Using CNAMEs makes your DNS data easier to manage. CNAME-records point back to an A record. So if you change the IP address of the A record, all your CNAME records pointed to that record automatically follow the new IP of the A record. The alternative solution is to have multiple A records, but then you would have multiple places to change the IP address which increases the chances of error.

The most popular use of the CNAME-record, is to provide access to a web server using both the standard www.domain.com and domain.com (without the www). This is usually done by adding a CNAME-record for the www name pointing to the short name [while creating an A Record for the short name (without www)]. Example:

You have a website with the domain name mywebsite.nl. This domain name is hooked up to an A-record which translates the domain name to the appropriate IP address, f.i. 11.22.33.444.

You also have several subdomains, like www.mywebsite.nl, ftp.mywebsite.nl, mail.mywebsite.nl etc. and you want this sub domains to point to your main domain name mywebsite.nl. In stead of creating A-records for each sub domain and binding it to the IP address of your domain, you create an alias, a CNAME-record. See the table below, in case your IP address changes, you only have to edit 1 A-record and all subdomains follow automatically because de CNAMES point to the main domain with the A-record.

(Sub)domain
Type
Target
mywebsite.nl

A
11.22.33.444
www.mywebsite.nl

CNAME
mywebsite.nl
ftp.mywebsite.nl

CNAME
mywebsite.nl
mail.mywebsite.nl

CNAME
mywebsite.nl
于 2015-03-18T08:13:59.787 回答