Dashways Logo
The Ultimate Managed Hosting Platform

How to Use a Custom Root / Naked Domain with Swipe Pages (Plus Bonus Tip: Wildcard Matching)

Marcus Wong
By Marcus Wong
/ January 12, 2021
< Back to Blog
Disclosure: The opinions expressed in this post are my own. This post may also contain affiliate links, which means that I will receive a commission if you decide to purchase through my links, at no additional cost to you.

So currently as of writing, the only way we are able to link up custom domains to Swipe Pages is with CNAME records.

It works flawlessly, but there is one minor problem. We aren't able to use just the root domain (a non-www version of the domain, also known as a naked domain). While that still stands true, we are however able to redirect the non-www domain to a www domain, which can then be linked to Swipe Pages via CNAME records.

CNAME Limitations

For those that aren't clear on the limitations of CNAMEs, here is a quick insight. CNAMEs cannot be used on the root of a DNS zone. Only an A or AAAA record can be used for the root. So for example, if you want to use dashways.com as your Swipe Pages custom domain, that is currently not possible, as Swipe Pages only offer connection by CNAME. Therefore, we use the subdomain www to connect to Swipe Pages, like this: www.dashways.com.

CNAME Record is also NOT Sufficient

Some of you may also say that you already prefer using a www domain. But that does not mean that setting up a CNAME is sufficient enough. Here's the problem, it is common, and in many cases, second nature, for people to omit the www when entering your website URL into the address bar. Without the right configuration, a user that types a non-www domain into the address bar will either see a broken site or a completely different site.

So in order for a non-www domain to be redirected to the www version, we need to set up a redirect rule of some sort.

Using Cloudflare for DNS

I will be using Cloudflare for this example. If you do not have a Cloudflare account, you can register for one for free. You do not need a subscription plan for the configurations I'm about to show you at all (I'm using the free plan myself).

How to Set Up non-www to www Redirect?

Follow along in this detailed walkthrough on how you can configure the redirection of your root / naked domain to the www version.

1) Prerequisites (Cloudflare)

Register for a free Cloudflare account, follow through with the setup and change your nameservers to the ones provided by Cloudflare.

Here is an example of changing nameservers on Namecheap:

Namecheap Nameservers

Once everything is verified, proceed to the next step.

2) Create Custom Domain on Swipe Pages

Go to your Swipe Pages dashboard, and go to the Domains tab, then click on Add New Domain. Enter your root domain here without the www, and go on to the next step.

Adding Root Domain to Swipe Pages

When asked to enter your subdomain, fill in "www", then proceed on.

Adding Subdomain to Swipe Pages

You will be given a VALUE field, copy that to your clipboard.

Swipe Pages CNAME

3) Set Up a CNAME Record on Cloudflare

On Cloudflare, head over to the DNS tab, and click on Add record.

  • Choose CNAME type
  • Under the Name field, input www
  • Paste the VALUE data you have copied earlier into Target field
  • Make sure your Proxy status is set to DNS only (grey cloud)
  • Click on Save
Add Cloudflare DNS Record
Cloudflare CNAME Record

4) Verify Your Custom Domain on Swipe Pages

Head back to Swipe Pages and click on the Connect button to verify your domain. You may need to wait until the DNS is fully propagated. Once done, create a sample page and map it to your custom domain to test that this is working. You should be able to load your page with the www in your subdomain.

Swipe Pages Connect Domain

5) Set Up Page Rule on Cloudflare

In order to redirect your non-www visitors to the www version, we will need to set up a page rule on Cloudflare. Head over to the Page Rules tab, and click on Create Page Rule.

  • In the first field, fill in your root domain (eg. dashways.com)
  • Next choose Forwarding URL from the dropdown menu, then 301 - Permanent Redirect.
  • Lastly for the destination URL, fill in the www version of your domain together with the https protocol (eg. https://www.dashways.com)
  • Click on Save and Deploy
Cloudflare Page Rules

Bonus Tip: Wildcard Matching (In Fact, You Should Do This Instead)

If you are intending to create a site with multiple pages, eg. www.dashways.com, www.dashways.com/services, www.dashways.com/contact, etc, then you will want your page rule to cover all your pages, not just for the homepage. With reference back to Step 5, use this version instead:

  • In the first field, fill in your root domain, and append with /* (eg. dashways.com/*)
  • Next choose Forwarding URL from the dropdown menu, then 301 - Permanent Redirect.
  • Lastly for the destination URL, fill in the www version of your domain together with the https protocol, and append with /$1 (eg. https://www.dashways.com/$1)
  • Click on Save and Deploy
Cloudflare Wildcard Page Rules

With this rule in place instead, all pages, not just the homepage, which are directly entered in as a root domain, will be redirected to the www version. As a general rule of thumb, you should be using wildcard matching by default.

In Conclusion

I hope that this guide gave you more clarity into how CNAME functions, and helped you out with your custom domain configuration on Swipe Pages.

In my next post, I will be sharing a little trick on how you can set up your CNAME once, and never have to touch it again even if you create new subdomains on Swipe Pages.

Marcus Wong
Article written by Marcus Wong
January 12, 2021

Leave a Reply

Your email address will not be published. Required fields are marked *