Deep links to /dashboard fail, home page works
- Likely cause
- Single page app without a rewrite to
/index.html - Fix
- Add the SPA 200 rewrite below
Fix a 404 on an AWS Amplify Hosting site: add the SPA rewrite rule, order redirects correctly, check wildcard syntax and confirm the build output folder.
On AWS Amplify Hosting a 404 usually means the requested path has no file and no rewrite rule sends it elsewhere. Single page apps need a 200 rewrite to /index.html, redirects are applied top to bottom, a rule with a bad wildcard is ignored, and a wrong baseDirectory in the build settings breaks routes. Check each in that order.
Four quick questions, then a straight answer.
From your answers, this is quietly costing you traffic and nobody has the hours to chase it. Scaplet finds every affected page, drafts the fixes and tracks how AI answers mention you.
A data platform shipped 46 fixes without a ticket.
This looks handled. Re-check after a redesign, a migration or a big content push; that is when it breaks.
Your site is small and you have the time. Work through the steps on this page, starting with the pages that get the most traffic.
/dashboard fail, home page works/index.html<*> is ignored<*>, at the end of the sourcehttps://example.com/path does nothingbaseDirectory does not match the build output folderhistory.pushState() to change the URL without a server request. That works for users who start at the root or /index.html, and "fails for users who navigate directly to any other page". The docs fix this with a 200 rewrite of everything except static file extensions.A status of 200 makes this a rewrite: the content is served as if it came from the original address and the browser bar keeps the original URL. That is different from a 301, where the address changes. Because file extensions are excluded, a missing .js or .png still returns a real 404, which is what you want when debugging.
[
{
"source": "</^[^.]+$|\.(?!(css|gif|ico|jpg|js|png|txt|svg|woff|woff2|ttf|map|json|webp)$)([^.]+$)/>",
"status": "200",
"target": "/index.html",
"condition": null
}
]version: 1
frontend:
phases:
build:
commands:
- npm run build
artifacts:
baseDirectory: build
files:
- "**/*"The Amplify docs say that if you get access denied for certain routes with an SPA rule, "the baseDirectory might not be set correctly". If your frontend builds to build, the settings must point to build. Amplify can store build settings in the console or in an amplify.yml in your repository, and the repository file wins for the branches that have it.
Run curl -sI https://main.d1234example.amplifyapp.com/dashboard and look at the status. A 404 on a route and a 200 on / confirms a missing rewrite.
In the Amplify console, open your app and its redirects and rewrites settings, then read the list top to bottom.
Rules with more than one <*>, a <*> that is not last, or a domain plus a path in the source are ignored without an error.
Amplify adds a trailing slash when needed for clean URLs: /about.html is served as /about when about.html returns 404, and /about/ serves /about/index.html.
After changing build settings, run a new build and request the failing path again.
A catch-all 200 rewrite means every unknown URL returns your app shell with a 200. Google says that when a 2xx page "suggests an error ... an empty page or an error message, Search Console will show a soft 404 error". If your SPA renders a not-found view, serve a real 404 for those paths with a rule of type 404 to a /404.html, and keep valid routes on the 200 rewrite. For the general meaning see 404 Not Found.
3 questions people ask next, answered from the sources on this page.
Add a 200 rewrite that sends all non-file paths to /index.html, using the regex from the Amplify redirect examples. Put it in the redirects and rewrites settings and redeploy if needed.
Amplify applies rules top to bottom, ignores sources with more than one <*> or a misplaced one, and ignores domain rules that contain a path. Reorder and simplify the rule.
No. Amplify lists a 404 redirect type that shows a destination page for missing addresses, and a 200 rewrite that serves another page as if it were the original. Choose based on whether crawlers should see an error.
Run the free audit, then approve the fixes. Every change can be undone.