Bulk redirect preserve path suffix not working

I reached out to Cloudflare support for help as this really stumped me. They shared some useful information which I’ve reposted below in case anyone else runs into a similar problem.


From Cloudflare support

(A) To redirect a subpath of www to the same subpath of the root domain, create a normal page rule with the following arguments:

(B) Page rules cannot be applied to pages.dev domains

(C) In order to setup a redirect on pages.dev you can use a _redirects file would look something like this:

/about https://pathoftrees.com/about-us 301

Note that the paths cannot match or it will create a redirect loop. Further details at: https://developers.cloudflare.com/pages/platform/redirects/


Conclusion

I have discovered that a bulk redirect can be applied to a pages.dev domain. So my final solution is:

  • Set up a www subdomain as per: https://developers.cloudflare.com/pages/how-to/www-redirect/
  • Use the page rule approach above to redirect the www subdomain to domain root (preserving subpaths)
  • Add a bulk redirect from our pages.dev domain to the root of our custom domain

Hopefully this helps anyone else struggling with this same topic :slight_smile:

1 Like