Skip to content

CloudFront redirect on 404 help

0

Hey all, so I have a private S3 bucket with full read to a cloudfront distro. I have a function to redirect files to an index.html on a folder, so if you goto http://example.com/folder1 it would like the file http://example.com/folder1/index.html. Works great. Now I want to send all 404 pages to a /404.html page.

I tried doing this in the error page section however its just giving the same error (which is actually a 200 but Access Denied). I tried to follow this - https://aws.amazon.com/blogs/aws/custom-error-pages-and-responses-for-amazon-cloudfront/ but still get that same error.

I have seen a few other posts, some making changes to the S3 bucket, but this is not set as static hosting, but I would think there is a way, I am just missing something simple.

Thanks all

asked a year ago610 views
2 Answers
0

Hello.

I tried doing this in the error page section however its just giving the same error (which is actually a 200 but Access Denied). I tried to follow this - https://aws.amazon.com/blogs/aws/custom-error-pages-and-responses-for-amazon-cloudfront/ but still get that same error.

I'm not sure what kind of error is occurring based on this explanation alone, but could you please share the specific error message?
In rare cases, the object path of the redirect destination is incorrect and cannot be displayed.
I think it is possible that some cache is left behind and the operation seems strange.
https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/custom-error-pages-expiration.html

Just to be sure, try clearing the CloudFront cache.
https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Invalidation.html

EXPERT
answered a year ago
  • Thanks for the replies. I am currently on my iPad / Chrome so the response is a bit different, but when I got goto a new URL thatI know doesn’t exist such as example.com/badpage123.html I get the following;

    AccessDeniedAccess DeniedE74NCHWK40BH0MPH984aITelIKEaDKHERKJnvpG1n3spskd1fQtmj1xBVB392D23BXMCKYdM1Q1JIoC4jshbCpQ77SY=

    I have a clean HTML file called 404.html and I just want all 404’s to go there, however I think the above is not sending a 404 but rather a 200 and just an access denied.

    I did create the error page setup in the distro - so in the error page section added an error page, type 404, goto 404.html with a 200 code.

0
  1. Private Bucket Access: Use an OAI to ensure CloudFront can access the S3 bucket.
  2. CloudFront Setup: Correctly configure the origin and behaviors to point to your S3 bucket.
  3. Custom Error Handling: Set up custom error responses to serve the 404.html page for any 404 errors encountered.
AWS
EXPERT
answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.