Bulk Redirect Priorities

What is the name of the domain?

What is the issue you’re encountering

Setting up bulk redirects

What steps have you taken to resolve the issue?

Sorry, basic question I am sure but new to Cloudflare.

Have set up several category level redirects from this site to another one and they work fine, redirecting from the category to the equivalent category on the destination site. What I also want to do is to set up a catch all so anything that isn’t covered by the specific category level redirects, would go to the homepage on the destination site.

What would be the easiest way of doing this for a non techie? Thank you.

How to distinguish between the URLs that have been redirected and the URLS that are not covered by your redirect rules? Any specific term?

Bulk Redirects are static, so unfortunately you won’t be able to create a catch-all rule that targets URLs dynamically there.

Instead, you could leverage Single Redirects. Because Single Redirects are executed before Bulk Redirects, you need to either create a rule that excludes all the URLs that are featured in your Bulk Redirects manually first (which is very cumbersome, but otherwise your Bulk Redirects will not work on overlapping URLs).

Or you could migrate your Bulk Redirects to Single Redirects and then leverage order of execution within Single Redirects. If you assign your new rule the lowest priority, Single Redirects would try to match on the rules that are higher on the priority list first, and if no match is found your new catch-all rule will get executed. This would be the easiest option in my opinion, if you don’t have many URLs to migrate.

Alternatively, you could leverage products that are executed after Bulk Redirects, for example Snippets. In this setup you can keep your Bulk Redirects in place and target the same hostname via Snippets. URLs that match with Bulk Redirects will get redirected, and the ones that don’t will invoke your Snippets code. Redirecting using JavaScript in Snippets is as easy as:

export default {
    async fetch(request) {
        // Redirect to this URL
        const destinationURL = "https://example.com";
        // With this status code
        const statusCode = 301;
        // Serve redirect
        return Response.redirect(destinationURL, statusCode);
    },
};

I’ve also had luck with using two Bulk Redirect lists. One with the specific redirects and its corresponding rule, then another Bulk Redirect List that uses appropriate matching (subdomain/subpath) with a single entry that points to the target.

1 Like