Anatol Zakrividoroga
Anatol Zakrividoroga

Reputation: 4518

AWS Amplify Redirects Gatsby 404 to Root URL

I have deployed a multi-page gatsby site both to AWS Amplify and Netlify.

When I go to a page that doesn't exist on my site that was deployed with Netlify, I get the 404 page I have created. But when I go to the same non-existent route on the site with Amplify, it redirects me to the root path.

I have checked the network tab, and I get a 404 status code without any HTTP redirects. So I assume the redirect happens in the JavaScript code?

Does this happen to anyone else?

Here is the default Rewrites and Redirects for my site on Amplify:

enter image description here

Upvotes: 5

Views: 2047

Answers (2)

Tapha
Tapha

Reputation: 1511

I exprienced this same issue, but with all pages reloading to the homepage if they weren't ended with a '/'. Removing all the rewrite rules seemed to fix this for me. I wasn't using any of them and they were set as defaults. Such as 'www' rerouting to '/'.

Upvotes: 1

Anatol Zakrividoroga
Anatol Zakrividoroga

Reputation: 4518

The solution was to change the target address from /index.html to /404.html like this:

enter image description here

Upvotes: 5

Related Questions