May 17, 2021 2 min read

Use Cloudflare to consolidate your domains with redirects in Page Rules

Use Cloudflare Page Rules to create redirect rules for old URLs and domains to a new domain.

Use Cloudflare to consolidate your domains with redirects in Page Rules

Back in 2018 when I started this blog, I wrote about using Azure Functions to redirect legacy domains to the new domain. I wanted to make sure that none of the domains I used before ended up with a 404, but redirected transparently to my new blog URL. The approach is still valid (although an easier approach using Function Proxy was shared in the comments), but it was getting a bit cumbersome:

  • You need a Function App running.
  • All my domains need SSL.

Even with just 3 lines of code, these things need maintenance and attention. Also, App Service Managed Certificates didn't exist back then (and are still in preview today), so I had a workaround solution using Let's Encrypt and an Azure Function to automate the renewal. It worked great unless when it didn't. Sometimes, one or more of the domains did not renew the certificate and I had to go in and trigger the renewal manually.
Moving parts need greasing to keep running and I was getting tired of greasing these particular moving parts. When I launched KEOS on Azure Static Web Apps, I ended up using Cloudflare because it worked around a preview limitation in Static Web Apps. It was my first introduction to Cloudflare and its services, but two things caught my attention:

  1. Free SSL certificates
  2. Page Rules

It was the exact solution I was looking for to do away my hacky Azure Functions and still have all those dangling URLs redirect to my blog!
So I moved all my legacy domains to Cloudflare DNS, turned on full SSL by Cloudflare and configured Page Rules:

  1. Open your Cloudflare dashboard and switch to Page Rules tab
  2. Click the Create Page Rule button
  3. Fill in the required information to redirect one URL to another, and it even supports wildcards with * and $1!
    In the screenshot ,I'm redirecting and subpages to a matching page with a Permanent Redirect:

My old (sub)domains (like and still work, but everything is now handled by Cloudflare!
It's just a small win, but I still took back some time that I can now use for something else.

Great! You’ve successfully signed up.
Welcome back! You've successfully signed in.
You've successfully subscribed to Yannick Reekmans.
Your link has expired.
Success! Check your email for magic link to sign-in.
Success! Your billing info has been updated.
Your billing was not updated.