Forwarding Naked Domain to www Subdomain

Wear something decent, domain!

14 Aug 2018
Back to blog

Websites on the internet have always been starting with "www" in front, at least during the young age of internet. The triple W translates to "World Wide Web". As for the true reason it was what it was: I do not know myself. Searches on the internet often leads to quite strange statements and confusing too. What I personally believe is that www is a mere subdomain, which canonically denotes the root/base of a site (like how may refer to blog, and refers to home). However, this is just a little bit of the story. There are more technical things going on behind the scene, particularly with DNS.

Well, this blog post isn't going to touch on the debate whether yes-www, or no-www. But since you already landed here, there is a possibility that you are a yes-www person and is looking forward to solve a forwarding problem.

My issue

I use a domain registrar (OnlyDomains) which provide DNS configuration for those who wants to make use of it. I have set up the DNS there and deleted the DNS for my website in my hosting panel in NearlyFreeSpeech (NFS). If you have read the FAQ , all you need to do when you use a third party DNS is to add a CNAME record pointing to the original default NFS URL of your website (e.g.: I did exactly that and everything went smoothly. Now people could visit my website whenever they type in

Unfortunately, I realised two days later that if a person typed the naked domain into the address bar, the DNS cannot point them to my site on NFS and give a "domain not found" error. It then came to me that I need to also handle the bare/naked domain so visitors could properly be forwarded to the NFS site. How to do this?

Taking consideration of other methods

In a common situation, usually you don't really end up in a problem like this. If you can delegate your domain registrar to another nameserver (your hosting's nameservers), then you could definitely do that. Once you did that, then all is left is to choose preferred URL in the respective panel on your host, or use .htaccess to canonically point to your www subdomain.

Of course, if you prefer to use a third-party DNS for example, Cloudflare, then we will need to use the approach listed below.


After thinking like a mad man, I came up to the obvious solution: we need to have a record which would handle the bare alias.

Introducing: A (or AAAA depending on your host if it uses IPv6) records! A/AAAA records point an alias you have set, to an IPv4/IPv6 address that you have also set to that alias. You can do this in two ways, directly use the real IP address of your site or use a forwarding service.

The reason why the bare domain is not resolved is because there are no DNS entry that specifically handle the bare domain requested by a user. The CNAME alias "www" only handle the address and not the bare domain. So this is where the A record comes in.

Directly use the real IP address of your site

Preliminary warning: Since this require the use of direct IP address, you need to know that some hosting providers do not provide an IP address for a site. This is because most hosting providers dynamically assign an IP address to your site based on multiple factors. Some hosting (like NFS) are a bit forgiving in this and may give you an IP address, but of course, you will never know if it changes. Therefore, you need to always remind yourself and check if the IP address of the site hasn't changed as opposed to the one you set in the new A record. Maybe, once a month or so. If your hosting provider do not provide an IP, then you don't have any other choice other than next method below.

Okay, for this method, you need to get the real IP address of your site from your hosting provider. If the address is an IPv4, you will have to create an A record. If IPv6, then AAAA record.

For the alias of the record, we just put "@" (without quotes) to denote the domain itself ( Then as for the value, we put in the IP address of your website.


Use a third-party redirection service

Alternatively, using third-party redirection eases the above con as it automates everything. Compared to the method above, this time you will need to find a redirection service that would do this for you. I have three free options that you may use:

Obviously, using a third-party redirection service means handing them 100% of your traffic, the ones where they entered the bare domain of your website in their address bar. This does not necessarily mean that it is bad. However, if you are really, really concerned about this, then you should instead use the previous method outlined before this section.

Okay, back on track, choose which forwarding service that you have a good feeling of and follow the instructions displayed on the chosen site.

As a simple outlook: you get an IP address then add a new A record pointing to such IP address.

Why 301redirect

As promised, I will explain why I recommend you to use 301redirect. Truth to be told, I only tested two redirection services: 301redirect and Naked Domain Redirect (NDR). At first I used the latter, but then I realise that if you directly type in your address with the https protocol, the domain lookup failed.

This is expected, because, someone needs to have the correct TLS files for my bare domain. Since NDR is not my host, I have no way to upload necessary TLS files for it. So I look up the internet to find more alternatives, until I found 301redirect which offers TLS (by Lets Encrypt) for your domains. This resulted in requests in the form of could be parsed and forwarded correctly.

Yes, TLS support is the cake here.


Okay that's all. I have nothing to add here.

Thank you for reading :)

Published on:

Get notified of new posts