Recently I moved my hosting and domain records from where I had them in Hungary (with Elit Info, brilliant people if you need no hassle stuff) to my own. Currently I do not have hosting, and I manage my domains through iwantmyname, and my DNS settings through CloudFlare.
Previously javorszky.co.uk and blog.javorszky.co.uk were pointing to different places; the blog. being my Ghost blog, and the other being a WordPress page where I didn't really have any content besides a few articles I no longer care about.
With my move the need for separate places stopped, so I thought let's consolidate all of these.
Therefore the new rules:
- https://javorszky.co.uk should be my Ghost blog (the naked domain)
- http://blog.javorszky.co.uk should 301 redirect to the naked domain
- http://www.javorszky.co.uk should 301 to the naked domain
- http://*.javorszky.co.uk should 301 to the naked domain
I'm using Ghost(pro), because even though I can set up hosting pretty much everywhere, I'd rather spend my time with actually contributing to Ghost than dealing with servers and whatnot. I have enough copies of it running in different commits anyways :P. Also, everyone should use Ghost(pro). Fact.
Reasons for this setup
So the main problem that people will encounter when they try to point their naked domain to their myNameIs.ghost.io address is that most nameservers have no idea how to deal with CNAME records on naked domains. CloudFlare provides a way. Ghost(pro) has a very good article about achieving what I'm going to basically repeat. For the most part. Except omit the bits that are already there.
Pitfalls / gotchas
On the domain setup page (https://ghost.org/blogs/domains/#setup) there's a tool mentioned called whatsmydns. I foolishly thought that if I set a CNAME on the root domain, that will show up there. Nope. This is what I got from a CloudFlare support email:
If you add a CNAME to the naked domain you will always see A records at the front since CNAME's at the naked domain is against the DNS spec, so CloudFlare will automatically resolve the CNAME for you and send back the A records that the original CNAME points to.
Therefore pinging whatsmydns and waiting until all those red x-es become green ticks is futile.
I've set 2 subdomain CNAMEs and a wildcard CNAME.
If you set a specific subdomain CNAME, CloudFlare will be caching that (tl;dr: it'll be fast), but it can't cache a wildcard rule for obvious reasons. Because I moved blog. to naked, that's something that's likely to see traffic. www. is also a common subdomain, so let's do that too. Everything else is a wildcard.
If you'd rather have www.yourblog.com and have yourblog.com redirect to the www. version, there's a separate article for pointing your www. address. It's easier to achieve I think.
Anyways, go froth and foam!
If in doubt (and you're a Ghost(pro) customer (which I assume you are if you're reading this article)), send an email to email@example.com, and they'll get back to you!