1

I am using an AWS S3 bucket, Cloudfront, and Route53. And for details of how I have my setup, here is a link to an answer I did telling people how to set this all up. If going to www.<MyWebsite>.com/about I get this:

This XML file does not appear to have any style information associated with it. The document tree is shown below.
<Error>
<Code>AccessDenied</Code>
<Message>Access Denied</Message>
<RequestId>PD94JP7DNG6TPDQF</RequestId>
<HostId>
qc0Fvl3fiS7igVeBEYfwvX19so0dH3hmIWNRBOcveK+j4DMmoPZQsxmbeA0XhFisy1BQvxmmrj8=
</HostId>
</Error>

But if I go to www.<MyWebsite>.com and using the navigation bar of my site go to the "about" section, I get there just fine. So AWS doesn't like me hitting the about url directly. What do I need to do to allow for any subpage do be hit?

This might be a duplicate of: Receive AccessDenied when trying to access a page via the full url on my website

If so then I will mark this as duplicate, standby.

Adam
  • 2,070
  • 1
  • 14
  • 18

1 Answers1

1

This sounds like your site needs to route requests through your index page. This would cause a HTTP 404 error, which could be masked by CloudFront as the 403 error you're getting here.

This can happen for example in React apps, where if it receives a request directly for /example, it would go and look in the S3 bucket for an 'example' file which doesn't exist. You can handle this by redirecting your 404 errors to your index page where it can be properly routed - in your S3 static website hosting settings, set Error Document to index.html.

chamal
  • 858
  • 6
  • 13
  • Okay, I set my error document to be index.html. So far still not working, but this was a great suggestion, and probably a big step closer to the overall fix. – Adam Dec 01 '22 at 06:51
  • Maybe this answer would help - https://stackoverflow.com/a/50302276/10354667 – chamal Dec 01 '22 at 07:24