Skip to content
StaticScope
Overview
Get StaticScope

URLs and 404s

Why a URL that WordPress answered can 404 as a file, and how to get trailing slashes, permalinks, case, encoded characters and the 404 page right.

Troubleshooting Updated 21 November 2026 6 min read

WordPress answers a request by running PHP and matching the URL against its rewrite rules. A static host answers by looking for a file. Almost every URL problem after a build comes from that one difference, including the strange case of an address that works perfectly in the editor and returns 404 the moment it is published.

What the build writes

A page is a folder with an index.html. The crawler turns a root-relative path into a file path like this:

Requested pathFile written
//index.html
/about//about/index.html
/about (HTML, no extension)/about/index.html
/media/photo.jpg/media/photo.jpg

Both permalink styles produce the same file: a document with no extension would otherwise be served as a download. The difference is what the host does with the request.

Trailing slashes

If your permalinks end in a slash, internal links do too and the file is /about/index.html. A host with an index document serves /about/ from it. Ask for /about and it must redirect, serve the index or 404. Netlify and GitHub Pages usually redirect. A bare nginx root can do none of those without a rule.

The reverse is equally common. Permalinks without a slash produce links to /about, and a host that only serves folder URLs may 404 it. The file exists either way; the request does not.

Choose one form and keep internal links in it. If visitors arrive in the other form, add a host redirect. Test both:

curl -sI https://example.com/about | head -5
curl -sI https://example.com/about/ | head -5

A 301 to the other form is fine. A 404 is a rule you still need. Two 200s mean duplicate addresses.

Permalinks

The permalink structure decides the folder layout, so changing it changes every URL the build writes. The build prunes files the site no longer uses, so a moved page loses its old address: correct for the build, wrong for anyone with a bookmark.

Change the structure, rebuild, then add redirects for the addresses that mattered. A static host cannot resolve a slug that no longer exists.

Case

Linux hosts are case-sensitive. macOS is not, by default, so a file called Photo.JPG linked as photo.jpg works on your laptop and 404s in production. This catches media more often than pages, because WordPress keeps the original file name and only lower-cases the slug.

Upload files in lower case with hyphens. When a page has a mixed-case link, fix the file name rather than adding a redirect. Test the exact case:

curl -sI https://example.com/wp-content/uploads/2026/11/Photo.JPG | head -3
curl -sI https://example.com/wp-content/uploads/2026/11/photo.jpg | head -3

Encoded characters

A space in a slug arrives as %20; accented letters arrive percent-encoded as UTF-8. The crawler queues the decoded address and writes a file with the decoded name, while the links keep the encoded form. The host has to decode the request the same way. Most do; some normalise differently, and a CDN in front can decode again or not at all.

So a page called Café can work in the preview and 404 on the host. The cheap fix is a slug rule: lower-case ASCII, hyphens instead of spaces, no emoji. If you need a non-Latin URL, test the encoded and decoded forms on the host first.

curl -sI 'https://example.com/caf%C3%A9/' | head -3
curl -sI 'https://example.com/café/' | head -3

Why a WordPress URL 404s as a file

In WordPress, almost any request reaches index.php. In a static build there is no PHP: if the crawler did not write a file at that path, the host has nothing to serve.

  • It was never crawled. The page is a draft, private, scheduled, excluded from the build or not linked from anywhere the crawler reached.
  • It is a query string. ?s=search, ?p=123 and ?preview=true have no file. Static search is a separate index, and a post ID means nothing to a host.
  • It is a WordPress endpoint. wp-json, wp-login.php, admin-ajax.php, xmlrpc.php and the feeds are removed on purpose. They cannot work without PHP.
  • It is an archive the build did not detect. Pagination past the last page, a date archive nobody linked, a tag with no posts. Detection options decide which exist.
  • The host will not serve it. No index document, no clean URL rewrite, the wrong document root or a redirect rule left over from WordPress.

Redirects are not generated

StaticScope follows redirects while it crawls, up to two in a chain, and records the ones it stops on. If an old address is in the crawl and your redirect plugin answers it, the crawler saves the destination content at the old address. The link works, but it is a copy rather than a redirect, and search engines see two addresses for one thing.

For a real 301, put the rule where the host reads rules: _redirects on Netlify and Cloudflare Pages, the server config on your own box, and the CDN in front of GitHub Pages or S3.

The 404 page

StaticScope saves your site’s own 404 response as /404.html. It asks for /404.html first, then a random path, and writes a plain fallback page if neither returns usable HTML. The filter staticscope_generate_404 turns it off.

The file matters more than it sounds. Cloudflare Pages treats a site with no 404.html as a single-page app and answers every missing URL with the home page and a 200 status. GitHub Pages and Netlify show their own generic page instead of yours. One is a soft 404 that search engines may index; the other is someone else’s branding.

Your 404 page is an ordinary static page. Links and images work; PHP does not. Keep it at the root of the published site, and check the status code rather than the appearance:

curl -sI https://example.com/this-page-does-not-exist | head -3
curl -s https://example.com/this-page-does-not-exist | head -20

You want a 404 status and your own copy. A 200 means something is rewriting missing paths to the home page or the 404 file. A default host page means 404.html was not published or is not at the root.

Testing the published output

The preview serves prepared files from disk. It does not apply host rules, so a URL that works in the preview can still 404 live. Test the published address, not the preview, for anything involving slashes, case, redirects or the 404 page.

  • curl -sI gives the status and any Location header. Follow redirects with -L and print the final address with curl -s -o /dev/null -w '%{http_code} %{url_effective}\n' -L <url>.
  • Run wp staticscope check --strict before publishing. It fails on missing files and pages that still point at WordPress.
  • Open Preview files and search for the exact path. If it is there, the host is wrong. If it is not, the build is.
  • Check the home page, one deep page, one archive and one media file. Those four cover most host rules.

Host rules worth knowing

Whatever the host calls them, you need four rules: an index document, a rule that sends extensionless paths to the matching folder, one canonical choice between www and the apex domain, and HTTPS enforced in one place. The fifth is a trailing-slash redirect.

Change the shape once. Every permalink, media and trailing-slash change breaks links people have already shared. Decide before launch where you can, and keep a redirect list for the rest.

Next