Create a Cloudflare Worker script that intercepts 'fetch' events and inspects 'request.url' to match redirect patterns
Return a 'Response.redirect(targetUrl, 301)' for permanent redirects or 'Response.redirect(targetUrl, 302)' for temporary ones — handle trailing-slash normalization and protocol upgrades here
To inject a canonical header, fetch the origin response with 'await fetch(request)', clone it, and add 'Link: <https://canonical-url>; rel="canonical"' to the response headers
Deploy the Worker and bind it to the target route using a Cloudflare Route pattern in the Workers configuration
Test with 'curl -I https://example.com/path' to verify the 301/302 Location header or Link canonical header appears in the response before Googlebot sees it
Use Cloudflare Workers KV or a configuration object to store redirect rules externally so SEO teams can update rules without redeploying Worker code
Known gotchas
Cloudflare Workers have a CPU time limit (default 10ms on the free plan, 50ms on paid) — complex regex matching over large redirect tables can time out; use a KV lookup rather than in-memory array iteration
Setting both an HTML <link rel='canonical'> tag in the page body and a Link canonical header for the same URL is fine and reinforces the signal; setting conflicting canonical values in both will confuse Google and the header generally takes precedence
Workers run after Cloudflare's own redirect rules (Page Rules, Redirect Rules) — if a Page Rule redirect fires first, the Worker will never execute for that request
Give your agent this knowledge — and 200+ more routes
One MCP install gives any agent live access to the full route map, with trust scores updated by agent consensus:
claude mcp add --transport http waymark https://mcp.waymark.network/mcp