



Ever noticed how some websites fail to return a page on typing "www.domain.com" but instead work only when "domain.com" is accessed?
I've just come across a few such sites today and thought I'd make a post here to educate with what I know.
To make your site accessible from both "www.domain.com" as well as "domain.com", you simply need to add an "Alias (CNAME) Entry". A canonical name (CNAME) record maps an alias to the real name. Note that an alias for www is often setup as a CNAME, so that requests to www.domain.com can be sent to the same website that handles the requests for domain.com.
So, the forward lookup zone would look some thing like
For example, while using Microsoft Windows IIS (web server), create a new web site for the domain using the IIS Manager, and add the domain (e.g. domain.com) as a new host header value listening to the same IP address as specified in the DNS entry. The port is set to 80 (the default for http requests). The host header can be added by clicking on the advanced tab next to the IP address configuration for that web site application. Set the home directory for the domain web site to the directory (e.g. C:\Inetpub\wwwroot\). Add another host header entry for www.domain.com so that anyone can access the website when typing with www in the beginning.
In case of Apache web server, the subdomain is configured by virtual host entries in httpd.conf as shown below.
I've just come across a few such sites today and thought I'd make a post here to educate with what I know.
To make your site accessible from both "www.domain.com" as well as "domain.com", you simply need to add an "Alias (CNAME) Entry". A canonical name (CNAME) record maps an alias to the real name. Note that an alias for www is often setup as a CNAME, so that requests to www.domain.com can be sent to the same website that handles the requests for domain.com.
So, the forward lookup zone would look some thing like
www IN CNAME domain.com.Care needs to be taken in your webserver configuration as well i.e., the web server needs to be configured appropriately to handle the request for the domain based on either the IP address or the host header entry. Host headers are commonly used by web servers to host multiple domains on one IP address.
domain.com. IN A 207.58.135.90.
For example, while using Microsoft Windows IIS (web server), create a new web site for the domain using the IIS Manager, and add the domain (e.g. domain.com) as a new host header value listening to the same IP address as specified in the DNS entry. The port is set to 80 (the default for http requests). The host header can be added by clicking on the advanced tab next to the IP address configuration for that web site application. Set the home directory for the domain web site to the directory (e.g. C:\Inetpub\wwwroot\). Add another host header entry for www.domain.com so that anyone can access the website when typing with www in the beginning.
In case of Apache web server, the subdomain is configured by virtual host entries in httpd.conf as shown below.
Listen 80
NameVirtualHost *
<VirtualHost *>
ServerName www.domain.com
DocumentRoot /home/httpd/htdocs/
</VirtualHost>
<VirtualHost *>
ServerName domain.com
DocumentRoot /home/httpd/htdocs/
</VirtualHost>


