Back to News & Insights
Web Development August 10, 2026 · 5 min read

How I Consolidated HTTP, WWW, and index.html URLs with a Cloudflare Worker

Google Search Console's "Page with redirect" report often looks more alarming than it is. On a...

How I Consolidated HTTP, WWW, and index.html URLs with a Cloudflare Worker

Google Search Console's "Page with redirect" report often looks more alarming than it is.

On a static site I maintain, Google discovered several historical forms of the same pages:

Only the last URL was supposed to be indexed. The others were not separate pages; they were alternate entry points left behind by older links, browser history, and previous deployments.

Every legacy URL should reach one canonical URL in one permanent redirect, and the canonical page should return 200.

This post shows the Cloudflare Worker pattern I used, the signals I aligned around it, and the checks that kept the redirect logic from creating new problems. Define the URL invariant first

For this example: HTTPS is mandatory. The apex domain is canonical; www redirects away. The homepage is /, never /index.html. Directory pages end with a slash. Known legacy paths map to their closest equivalent page.

Writing these rules down matters. If the Worker, canonical tags, sitemap, and internal links disagree, crawlers receive conflicting signals. Run the Worker before static assets

With Cloudflare Workers Static Assets, the Worker needs to see the request before an asset is served:

Cloudflare documents the ASSETS binding and runworkerfirst behavior in its Static Assets documentation. Normalize host, protocol, and legacy paths in one pass

The important detail is that protocol, host, and path are normalized before returning a response. A request for:

The URL copy also preserves the query string by default. Do not delete arbitrary parameters unless you know they are non-functional. Removing a parameter that changes page content can merge pages that are not actually equivalent. Keep redirects specific

A removed page should redirect only when there is a genuinely equivalent destination. Otherwise it should return a proper 404 or 410. Sending every missing URL to / confuses users, hides broken links, and can be treated as a soft 404.

The explicit Map makes migrations reviewable. It also prevents an innocent path rewrite from affecting API endpoints or static files. Align every canonicalization signal

Internal navigation also links directly to the final URL, not to a URL that needs a redirect.

Google's canonicalization guidance recommends self-referencing canonicals and consistent internal links. Its sitemap documentation likewise says to include the preferred canonical URLs rather than every duplicate form: Canonical URL best practices Build and submit a sitemap Test the entire redirect matrix

Also test a real 404, query parameters, nested legacy paths, and any API routes. A redirect system is not finished until its negative cases behave correctly.

Assert that every source returns 301, has the exact expected Location, and reaches a 200 response without another hop. Interpret Search Console correctly

After deployment, old URLs may remain in Search Console under Page with redirect for a while. That category is normally expected: Google discovered the source URL, followed the redirect, and chose not to index the source.

Want to discuss this further?

Book a free strategy call with our team to see how these insights apply to your specific business goals.

Book a consultation