AWS Amplify Static site not routing as expected. Needs a final urls need a final '/'

1.1k Views Asked by At

Serving a site from AWS Amplify I noted a problem that all my category pages just looked like the home page. I thought this may be a template issue or something but I downloaded the artifacts and confirmed that the pages were being formed as they should have.

I narrowed down the problem to routing.

For example http://example.com/some-uri returns a page, that is actually my homepage not a 404 and not a redirect to my homepage. However http://example.com/some-uri/ routes to the correct resource, for example /some-uri/index.html.

This behaviour kind of puts me off using pretty permalinks as my development server does not require the trailing /.

2

There are 2 best solutions below

1
On

I have worked around this by serving my page from /some-uri.html not /some-uri/index.html and will post a more comprehensive answer if I work out how it all works.

0
On

Amplify has a pretty advanced "rewrites and redirects" and configuration panel and a section in the documentation on establishing desired routing.

The following section suggests that the expected behaviour, of routing from /some-uri to /some-uri/index.html should be automatic.

https://docs.aws.amazon.com/amplify/latest/userguide/redirects.html#trailing-slashes-and-clean-urls

I found this to be the case, but only when I removed the rule that was present at time of creation redirecting all 404 back to my homepage.