(Updated: )
/ #cdn #dev-decoded #productivity 

The step-by-step guide to create a domain redirect with Cloudflare

Redirecting a whole domain using Cloudflare can be useful but isn’t documented anywhere, here’s how to do it.

Pre-requisite:

  • Be logged into your dashboard.
  1. Select the domain you want to redirect from

  2. Go to page rules

  3. Click “Create page rule”

  4. Enter your.domain/* (matches all traffic) for which URLs will have their traffic redirected

  5. Click “Add a Setting”

  6. Select “Forwarding URL”

  7. Select the type of redirect, I recommend 302s since they’re less aggressively cached (so if you ever want to use that domain to do something else other than redirect, you can)

  8. Enter your forwarding URL

  9. Click “Save and Deploy”

You’re done, you’ve just created a redirect from your domain to another one 🙂

unsplash-logoAndrew Preble

Author

Hugo Di Francesco

Co-author of "Professional JavaScript", "Front-End Development Projects with Vue.js" with Packt, "The Jest Handbook" (self-published). Hugo runs the Code with Hugo website helping over 100,000 developers every month and holds an MEng in Mathematical Computation from University College London (UCL). He has used JavaScript extensively to create scalable and performant platforms at companies such as Canon, Elsevier and (currently) Eurostar.

Get The Jest Handbook (100 pages)

Take your JavaScript testing to the next level by learning the ins and outs of Jest, the top JavaScript testing library.