IT Nota

  • Home
  • How To
  • .NET
  • WordPress
  • Contact

How to Setup Naked Domain to Resolve in Cloudflare Pages

If you’ve never tried Cloudflare static site hosting, Cloudflare Pages is great for speed and worldwide distribution. One hiccup I encountered because of the way the DNS was setup in Cloudflare when using a custom domain. If you want to include the www prefix, it won’t resolve properly by default and you will see a page error.

The problem is Cloudflare just gives an instruction to add a CNAME record with ‘www’ and content to your Cloudflare Pages URL it provided you. Once done, it would still give you another warning like the following:

Cloudflare DNS warning CNAME root domain

A few more steps are required to complete your setup.

Add an A, AAAA, or CNAME record for your root domain so that itnota.com will resolve.

Now, this is interesting because I was not given any other hints or IP address to create an A or AAAA record and CNAME can only be used on subdomains, including ‘www.’

I think in reality, you can ignore the warning and go ahead create a page rule anyway, but that does bug me so the other possibility is to create another CNAME with @ and the same forwarding address similar to the ‘www’.

Then you will get another warning:

Cloudflare Pages CNAME flattening DNS

Because CNAME records are not allowed at the zone apex (RFC 1034), CNAME flattening will be applied to this record.

And this point, you will still get an error message if you use naked domain to go to your page.

To solve this we need to setup a Page Rule to redirect the naked domain to the www.

Steps

  1. In Cloudflare, go to your corresponding domain and on the icon menu on top of the page, select Rules and click the Create Page Rule button.

    Cloudflare Create Page Rules

  2. In Edit Page Rule screen, type in your naked domain name with forward slash and asterisk (e.g., itnota.com/*).

  3. On the next line, select Forwarding URL from the first drop-down and 301 – Permanent Redirect.

  4. Then in the last textbox, you want to type in the proper URL where you want to redirect the traffic to, which in this case is https://www.inota.com/$1. $1 is like a wildcard to take any strings after the last forward slash.

    Your final setting should be similar to the screenshot below.

    Cloudflare Edit Page Rule Forwarding URL 301 settings

  5. Don’t forget to click the Save button.

  6. Once done, just make sure that the rule is active by making sure that it’s turned on (the button with green color on the right).

    Cloudflare Page Rules 301 Redirect On

That’s all there is to it. This time, if you type in something like itnota.com in your browser, it will direct your browser to the proper URL and there’s no more error message.

Further Reading

How to Install Hugo on Windows 10
How to Setup Visual Studio Code for Hugo Static Site Generator
How to Deploy Hugo Static Website to IIS Using Git

August 2, 2021 Filed Under: How To Tagged With: JAMStack

Buy me a coffee?

Buy me a coffee If you find any of the articles or demos helpful, please consider supporting my work here, you'll have my big thanks!

Buy me a coffee Support this site
Buy Me a Coffee?

Categories

  • .NET
  • Coding
  • Cybersecurity
  • Database
  • How To
  • Internet
  • Multimedia
  • Photography
  • Programming
  • Resources
  • Review
  • Tips and Tricks
  • Uncategorized
  • Use Case
  • WordPress
  • Writing

Recent Posts

  • How to View Stored Procedure Code in SQL Server
  • How to Find a String in SQL Server Stored Procedures
  • How to Remove Cached Credentials without Rebooting Windows
  • ESP Work Automation: Empowering Enterprises with Streamlined Workflows and Operational Efficiency
  • How to Search for a String in All Tables in a Database

Recent Posts

  • How to View Stored Procedure Code in SQL Server
  • How to Find a String in SQL Server Stored Procedures
  • How to Remove Cached Credentials without Rebooting Windows
  • ESP Work Automation: Empowering Enterprises with Streamlined Workflows and Operational Efficiency
  • How to Search for a String in All Tables in a Database

Tags

.NET .NET Core AdSense ASP.NET Cdonts Dll Classic ASP Code Editor ETL FSharp Genesis Framework Git Google HP Asset Manager HTML5 Hugo IIS Information Security Internet Internet Information Services iOS JAMStack Linux macOS Microsoft Microsoft SQL Server MVC PHP PowerShell Python Simple Mail Transfer Protocol Smtp Server SQL SQL Server SSIS SSMS SSRS Sublime Text Visual Studio Visual Studio Code VPN Windows Windows 8 Windows 10 Windows 2012 Windows Server

Copyright © 2011-2025 IT Nota. All rights reserved. Terms of Use | Privacy Policy | Disclosure