Redirect multiple domains to one site using Cloudflare

If you’ve got more than one domain (such as example.co.uk, example.uk, example.io etc.) that you want to be redirected to the same site (example.com), then it can easily be configured using Cloudflare’s PageRule functionality.

Steps

This guide assumes you’re already using Cloudflare’s services for all the domains to be redirected and have caching/performance enabled (i.e. not DNS only). If not, go follow this guide from Cloudflare

  1. Navigate to the “Page Rules” tab for the domain to be redirected
  2. Click “Create Page Rule” button
  3. Enter the following as the URL criteria: domaintoberedirected.tld/
  4. Click “Add a Setting” link
  5. Choose “Forwarding URL” dropdown
  6. Select the status code of your preference, either permanent or temporary (if you want to revert back in the future)
  7. Enter the destination URL from the following examples
  8. 7a) To have the rest of the URI structure maintained (i.e. domaintoberedirected.tld/page1 -> domain.tld/page1) use: https://domain.tld/$2 (replacing https with http and/or domain.tld with www.domain.tld if desired)
  9. 7b) To have all pages redirect to the same location (i.e. domaintoberedirected.tld/page1 -> domain.tld) use: https://domain.tld/oldbrandblogpost (replacing https with http and/or domain.tld with www.domain.tld and/or changing the specific page if desired)
  10. Repeat steps 4 through 7, with the URL criteria of .domain.tld/

You can then check the results by browsing to the old domains, which should now be redirected.

If it doesn’t work, triple check the settings for your domain have caching and performance enabled (orange cloud).

Image Credit:

Benjamin Ragheb

Leave a Reply

Your email address will not be published. Required fields are marked *