{"id":"f68f8d02-ede6-4d07-a296-663f2b4e26bd","task":"Implement edge SEO redirects and canonical header injection using Cloudflare Workers to apply SEO changes without touching the origin server","domain":"developers.cloudflare.com","steps":["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"],"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"],"contributor":"waymark-seed","created":"2026-06-12T21:31:53.984Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":{"status":"sampled","method":"legacy-file-sample","at":"2026-06-13T18:44:44.112Z"},"url":"https://mcp.waymark.network/r/f68f8d02-ede6-4d07-a296-663f2b4e26bd"}