What is a CNAME, Why should I use a CNAME and How do I create a CNAME?

What is a CNAME, Why should I use a CNAME and How do I create a CNAME?

What is a CNAME?

Before baffling you with the technical definition of what a “CNAME” is, let me explain to you in layman’s terms exactly what it is and what it does.

In short, a CNAME is a method by which one can label a resource that is not hosted on your server with a shortened URL.

Let’s assume therefore that you own the domain eggcups.com and you host your website with mywebhosting.com (the names here are irrelevant and provided for illustration purpose only). You have images and files that you host on Amazon S3, Rackspace or another content delivery network and you wish to make it look like those resources come from eggcups.com – how can you do this? With a CNAME.

For example:

images.eggcups.com can link to images.eggcups.com.aws.amazon.com
myexe.eggcups.com can link to 127.31.23.49

A CNAME operates a domain level and therefore is a much cleaner and professional way in which to link resources together than with a clumsy HTML or JavaScript redirect script.

The technical definition of a CNAME is a record or canonical name by which one can create a record in the DNS that specifies a IP which to access.

Why Should I Use Them?

The primary reason for using CNAMES is to give the illusion that a user is still on your domain hosting whilst in fact they are accessing resources from another server that you control.

Example 1: Improve Image Loading Time & Reduce Web Hosting Bandwidth

Assuming that you have already web-optimized your images, this is a great way in which to additionally speed up the loading times of your images. It also reduces the risk that your website is taken offline due to resources of your web host being over used.

A content delivery network, Amazon S3 for example, will send your images to the user from the nearest server.

Your images will appear as if they are coming from your server – albeit on a subdomain- once you’ve created a CNAME.

Example 2: Software Application That “Calls” Home

It’s not uncommon for software developers to decide that they want their application to call home to check for updates on loading. However, this can put serious strain on ones server when users build up over time.

By hosting the server side script on a content delivery network, you reduce the amount of PUT requests on your server and are easily able to scale your requirements thanks to the cloud.

In this method, your server won’t slow down due to too many PUT requests – in short, your webhost won’t think that your server is under attack from a bot!

Example 3: Large Files & Bandwidth Heavy Items

Let’s assume that you distribute an application albeit as a EXE or ZIP file on your server. The file might be big or small, however, now let’s assume that your linked to by a huge site – your hosting could quickly go offline due to excessive bandwidth requirements. You’d be a victim of your own success.

Using the cloud you will be able to pay for what you use in terms of hosting, moreover, you can give the impression that you are hosting the resources that you are providing on your own server.

How Do I Create Them?

In order to create a CNAME you’ll need access to configuration at a server level. You will be unlikely to be provided this on a basic web-hosting package and will need to request that a web-host makes these changes for you.

An example template to ask for such a change to your hosting would be:

Hello,
I’m writing to request that you create a CNAME:
Can you please create a CNAME on mydesiredCNAME.mydomain.com to resourceurl.com
Thanks and Regards,
Daniel Offer

If, however, you have access to server configuration and you’re feeling adventurous – or you just don’t want to have to ask the web-host to create a CNAME for you. Then follow this tutorial.

Step 1: Open up your We bhosting Management suite e.g. WHM (normally, yourdomain.com/whm if you have it) 



Step 2: Search for “Edit DNS Zone” and select it.

Step 3: Select the domain DNS which you wish to edit from the list.



Step 4: Your current DNS settings will be shown, don’t edit these unless you understand what you are doing.



Step 5: Scroll all the way down to see the ability to add another CNAME, you will need to click “select” from the drop down menu to select “CNAME” you will then be able to enter the domain which you wish to link to.



The format is the “subdomain” on the far left, CNAME in the middle and the domain which you wish to link to in the far right. Once you are finished, press “save”. Visit the CNAME to test your changes.
Farhamdani

Sharing insights on tech, blogging, and passive income. Follow for more at farhamdani.eu.org!

Drop your comments, but make sure they’re related to the discussion!

I'd be grateful if you could read the Commenting Rules on this blog before posting a comment.

Post a Comment (0)
Previous Post Next Post