Imagine you've just bought a new domain for your next side project, haven't got a website for it yet but don't want it to point to the void as well. My usual approach to this in the past was this:
- Set up the A record of the domain to point to the IP address of my main website.
- Update the webserver configuration for that site to listen to the new domain.
- Once the side project is ready, revert the settings and update the A record with a new IP address.
Although this is easy enough, it still requires updating an unrelated site, and what if you don't have an existing site to use as a temporary placeholder?
This was the case when I wanted to redirect my (super old) domain jerome-gamez.de to my current gamez.name. I was already on my VPS to update the configuration when I started to wonder if there was a simpler solution - I think I found one using Cloudflare DNS and Page Rules, and I'd like to share it with you today.
If you haven't already, create an account at Cloudflare (it's free), add your site and point your domain's NS records to the nameservers named on your site's dashboard.
On the DNS dashboard, enter the following entries:
I'm not sure if the
www entry is really needed - I created it to be sure, and it at least didn't break anything
On the Page Rules dashboard, create a new page rule:
In case of a temporary forward, use
302 as the status,
Most of the time, the process of propagating the settings is a matter of only a couple of minutes, but it took more in some cases. You can check the current progress on whatsmydns.net.
Once this is done, your domain (and any path on it) should redirect to the target configured in the page rule.
Try it out as much as you want on my domain, for example at https://jerome-gamez.de/you-wont-believe-what-happens-next or https://www.jerome-gamez.de/www-works-too and send me some traffic - but don't be disappointed, there's nothing interesting to see :).