You have decided on a domain name and have verified it is available. That’s a great first step to getting your website or application online. Configuring the DNS settings associated with your domain can be complicated depending on your needs, but for many cases is a painless process.
The domain you purchased, let’s say this domain is “example.com”, can be mapped to an ip address of your choosing. This ip address will be the ip address of the web server that your website is running on. Let’s imagine this ip address is “184.108.40.206.”
First we need to create an A Record
Login to your domain provider’s website and locate the Domain Naming System (DNS) settings for your domain name. You should see an option to create an A record. This is what creates the link between your domain name and your ip address, so in our hypothetical case, your entry should look like this:
The @ symbol refers to your domain name ( example.com in our case ).
The value is the ip address of your web server. TTL is an acronym for Time to Live and dictates how often a resolver will check for a new value for the record. For those wanting to dive deeper into TTL, I recommend this explanation, but in most cases you can let the provider handle this by setting the TTL to ‘Automatic.’
At this point you have done all that is required for your website to show when you type http://example.com into your web browser. But don’t expect it to work right away. Though theses changes generally occur quickly, it can take up to 24 hours in some cases. But let’s not spend that time twiddling our thumbs. We have more work to do!
Allowing the WWW Sub Domain
So we have http://example.com setup, but what happens if someone types http://www.example.com? Having your domain name with the prefix ‘www’ point to your website is not a requirement, but it’s recommended. Many people are still accustomed to typing ‘www’ before any web address, and you want people to find you easily, so let’s make sure that works.
Go back to the DNS settings page you used when creating the A record. Add another entry, but this time we do not want an A record. We want a CNAME. A CNAME serves as an alias for a domain name, and because you already have your A record that handles ‘example.com’ you can create a CNAME of ‘www’ that points to that same domain.
Implementing a Permanent Redirect
Now, we could consider this done, but I recommend one last thing. I recommend creating a permanent redirect from www.example.com to example.com. You might be thinking “what a minute, we just did that.” Ok, let me explain.
By creating the CNAME we will be able to type in www.example.com and have our website render. And because of our A record we can type in example.com without the ‘www’ and it will also show up. This is great, but it creates a new problem. If you are wanting to grow an audience and you want to know how many people are accessing your website, you don’t want unnecessary entry points to your website, as these will be treated as separate websites, so in our present case, you might not be seeing an accurate number if you are only tracking metrics for example.com and not for www.example.com. And if you were to take them both into consideration you would still have the issue of having to add them together in order to make informed decisions regarding growing your audience. We can avoid this altogether by creating a permanent redirect.
So once again, go back to your DNS settings and let’s add that.
Now when you type www.example.com the end result will appear the same unless you pay careful attention to the address bar. The ‘www’ should have disappeared due to the redirect and should simply read example.com. So now all of your traffic is being funneled through a single domain. Congratulations on a job well done
This concludes this tutorial. From here I recommend enhancing the security of your website using SSL. This process has become more and more important and can be done for free.