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:
- Free SSL certificates
- 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:
- Open your Cloudflare dashboard and switch to Page Rules tab
- Click the Create Page Rule button
- Fill in the required information to redirect one URL to another, and it even supports wildcards with
In the screenshot ,I'm redirecting
www.yannickreekmans.beand subpages to a matching
https://blog.yannickreekmans.bepage with a Permanent Redirect:
My old (sub)domains (like https://yannick.reekmans.be and https://www.reekmans.be) 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.