Skip to content
StaticScope
Overview
Get StaticScope

Redirects and 404s

What StaticScope records about redirects, what it does not generate, and how to keep old URLs working at the host.

Features Updated 20 November 2026 5 min read

Redirects are where a static site most often surprises people. In WordPress a redirect plugin answers a request before the page loads. On a static host there is no PHP to run it, so the rule has to exist as a file or as host configuration.

StaticScope does not generate redirect files. It follows redirects while it crawls, records the ones it stops on, and leaves the rest to the host. This page explains exactly which part does what.

What happens during a crawl

The crawler requests each queued URL and follows up to two redirects. When a URL redirects to a page, the response at the end of the chain is saved at the address that was crawled. A chain longer than that ends on a redirect response.

That response writes no page for the URL. Instead it stores a row in the copy cache with the source URL, the status code and the target. The record is data, not a published file.

No redirect files. StaticScope does not write _redirects, netlify.toml, nginx rules or meta refresh pages. If an old URL must redirect rather than show a page or a 404, you add that at the host.

Where the redirects are recorded

The copy cache is the table behind StaticScope → Caches → Copy cache. Each row holds the URL, a hash, the HTTP status and, for a redirect, the target as a root-relative path where possible.

The rows are exposed through the staticscope_list_redirects filter, which returns an array keyed by source URL with url and redirect_to. That is the hook to use if you want to generate host rules yourself:

wp eval 'print_r( apply_filters( "staticscope_list_redirects", [] ) );'

Treat it as a report of what the crawler saw, not a complete map of your redirect plugin’s rules. A redirect the crawler followed leaves no redirect record: only the destination content was saved.

Redirect plugins

Plugins such as Redirection and Simple 301 Redirects store their rules in WordPress and answer requests in PHP. None of that runs on the static host. What happens at build time depends on whether the old URL is crawled:

  • If the old URL is in the crawl and the plugin redirects it, the crawler follows to the destination and saves the destination content at the old address. The link keeps working, but it is a copy of the page, not a redirect, and search engines see duplicate content.
  • If the old URL is never crawled, nothing is written for it. The host answers with your 404 page.
  • Rules with conditions (logged-in state, country, referrer, A/B tests) cannot be reproduced from a static file at all.

Host rules

Netlify and Cloudflare Pages read a _redirects file from the top of the published site. The GitHub add-on keeps that file when it publishes, so you can add it to the branch once and leave it there. Each line is a source, a destination and a status:

/old-page /new-page 301
/guides/* /docs/:splat 301
/temporary /new-page 302

On your own server, put the rules in nginx or Apache config. A 404 handler belongs there too:

location = /old-page {
    return 301 /new-page;
}

error_page 404 /404.html;

GitHub Pages has no server-side redirects. Keep the old path as a real page, put Cloudflare in front and use its rules, or use a meta refresh page as a last resort. S3 stores files and does not read a redirects file. CloudFront Functions or the CDN in front of the bucket is where the rules go.

301 or 302

Use 301 for a permanent move: the old URL is gone and the new one is the address. Use 302 or 307 for something temporary, such as a seasonal page or a short campaign. Browsers and search engines cache a 301 hard, so a wrong permanent redirect is annoying to undo.

A meta refresh is a page with a 200 status that asks the browser to move on. It works everywhere, including GitHub Pages, but it is a soft redirect: there is no 301 to pass signal, and it breaks for anyone who does not run the refresh. Use it only when the host gives you nothing better.

Trailing slashes

StaticScope writes a directory with an index.html. A permalink ending in a slash becomes /about/index.html. A permalink without one, when the response is HTML and the path has no extension, also becomes /about/index.html. Both forms therefore resolve on a host that serves directory indexes.

Pick one form for internal links and keep it. If visitors arrive on the other form, add a host redirect from /about to /about/ rather than relying on the host’s fallback behaviour, which varies.

Testing redirects

The preview serves the prepared files as plain static files, so host rules do not apply there. Test redirects on the published site: curl -I https://example.com/old-page shows the status and the location header. Check that the target returns 200 and is the page you meant.

Also test a URL that should not exist. The crawler saves the site’s own 404 page as /404.html, or writes a plain one when WordPress serves none, and staticscope_generate_404 can turn that off. Configuring the host to use 404.html is a separate step, described under your host.

What cannot work statically

  • Rules that depend on who is asking: logged-in users, roles, countries, cookies, referrers.
  • Redirects that exist only as WordPress PHP, including most redirect plugin rules until you recreate them at the host.
  • Redirecting a POST. A static host has nowhere to send the body.
  • Redirects to a URL that is not in the build. The rule will fire and land on a 404.
  • Redirecting back to the WordPress site. That publishes your editor address and defeats the point.
  • Changing a status code after publish unless you can change the host rule and redeploy it.

When the site address changes

Links in the prepared site are written for the published address at build time. Change the address in Settings and build again; the add-ons warn when a prepared site was built for a different address. Keep redirects from the old domain at the DNS or CDN layer, since the static files cannot know about it.

Next