How to Set Up a CNAME With GoDaddy

By Steve McDonnell

When you create a subdomain on your website, a CNAME record that contains the name of the subdomain and the IP address of the server must be added to the GoDaddy DNS server for your website. Unless you run more than one Web server, the IP address for the subdomain is the same as the IP address for the primary domain.

Add a CNAME Record

Log in to the GoDaddy site and launch the domain editor. Locate your domain and select the option to edit the DNS Zone File. Choose "Add Record" and select a "CNAME (Alias)" record. Type the name of the subdomain in the Host field, and type the IP address of the subdomain, or "@" if it's the same as the primary domain, in the Points To field. Accept the default TTL value and select "Finish." It can take up to 24 hours for the CNAME to propagate to all DNS servers around the world.

Create a Virtual Host

When you add a CNAME to a domain, it means that users can address traffic to that subdomain and that DNS servers will route the traffic to your Web server. However, you must tell the Web server what to do with the traffic that arrives for the subdomain, or it will resolve the default location for traffic with an unknown destination. You can do this by creating a virtual host for the subdomain. For example, in Apache, use the ServerName directive to provide the subdomain name and the DocumentRoot directive to provide the location of the code for the subdomain:ServerName mail.example.comDocumentRoot /var/www/example-mail/htmlErrorLog /var/log/apache2/exm-error.logCustomLog /var/log/apache2/exm-access.log combined