148 words
1 minute
Redirecting a whole domain with Cloudflare
Redirecting a whole domain with Cloudflare
I had to run this site on til.simonwillison.org
for 24 hours due to a domain registration mistake I made.
Once I got til.simonwillison.net
working again I wanted to permanently redirect the URLs on the temporary site to their equivalent on the correct domain.
Since I was running the site behind Cloudflare, I could get Cloudflare to handle the redirects for me using a Page Rule, which support wildcards for redirects.
I used these settings:
- URL:
til.simonwillison.org/*
- Setting: Forwarding URL
- Status code: 301 (permanent redirect)
- Destination URL:
https://til.simonwillison.net/$1
This did the right thing - hits to e.g. https://til.simonwillison.org/cloudflare?a=1 redirect to https://til.simonwillison.net/cloudflare?a=1
Here’s a screenshot of the settings page I used to create the new Page Rule:
Redirecting a whole domain with Cloudflare
https://mranv.pages.dev/posts/redirecting-a-whole-domain-with-cloudflare/