top of page
Search
  • Writer's pictureAndrew Boyd

Hosting a domain on WWW with Cloudflare

Updated: Jul 18, 2022

These instructions assume you have logged into Cloudflare and that you have set up your Domain & DNS records, and are on the Page Rules page.


Get traffic off your naked domain (i.e. yourdomain.com)

  1. Select "Create Page Rule"

  2. Populate the fields with these values:

    1. URL: yourdomain.com/*

    2. Pick a Setting: Forwarding URL | 301 - Permanent Redirect

    3. Enter destination URL: https://www.yourdomain.com/$1 (note we're sending them to HTTPS and $1 passes everything passed in through the wildcard)

  3. Select "Save Page Rule"

Ensure your traffic is on HTTPS & cache all files on your domain

  1. Select "Create Page Rule"

  2. Populate the fields with these values:

    1. URL: www.yourdomain.com/*

    2. Pick a Setting: Cache Level | Cache Everything (This was what I wanted, but you simply pick what is appropriate to you, of course, if you want to cache only files in a certain folder, you will need to set up a new rule to achieve this)

    3. Add a Setting: Always Use HTTPS

Testing your DNS

I've written a small web application that will give you a suite of URLs to test based on a URL for your domain.



Troubleshooting your DNS

At the time this was written, if you chose "Always Use HTTPS", you don't have the option to add another rule, which is why I say to pick your cache level first


If you see an error similar to the below message, when you navigate to your domain, it could be because you've left the wildcard off your URL.

Server encountered an internal error. Please try again after some time.

HttpStatusCode: 500
ErrorCode: InternalError
RequestId : baa3ba74-501e-0092-1ccd-7d4eef000000
TimeStamp : 2022-06-11T19:58:21.6557218Z

28 views0 comments

Recent Posts

See All

Don't use ILogger

In a project recently, I noticed while ILogger was being passed into API controllers, it wasn't being used as much as it should, so I questioned, What would make developers consider their colleagues i

Don't use Configuration!

One of the most used classes in .NET Core would have to be IConfiguration, found in the Microsoft.Extensions.Configuration Nuget package. You can access your configuration using Configuration["ASectio

Development Frustrations

I got to do some React work this week, which has been an educational experience, a lot went wrong that shouldn't have and I learnt a few lessons which I thought I'd share. Slow navigation I logged int

Post: Blog2_Post
bottom of page