Skip to main content
AI Assist is now on Stack Overflow. Start a chat to get instant answers from across the network. Sign up to save and share your chats.

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

29
  • 10
    this worked like a charm for me, only the custom error code I needed was 404, not 403 Commented Oct 24, 2016 at 0:57
  • 4
    A bit of a hack, but works great :) It'd be nice if CloudFront just let us map a range of paths to a S3 file (without a redirect). Commented Dec 15, 2016 at 6:36
  • 2
    @NathanielMaman because you could have two origins in your cf distrib. .com/app (s3) and .com/auth (ec2/whatever). Error responses are top-level, so there is no way to tell the diff between an s3 403 and a 403 from /auth or anywhere else. The private, preview-only Lambda@Edge is the fix and is a ridiculous solution to mod_rewrite. Commented Jan 13, 2017 at 16:23
  • 8
    This is not working for me. This solution always redirects to the home page and not the correct pages... Commented Nov 5, 2019 at 0:20
  • 5
    This solution leads to a "slow initial server response time" error in pagespeed or other popular tests. Every time, the cloudfront request tries to find it, errors out, and redirects to error page. This happens for every page load and seem quite wasteful. Is there another approach that doesn't take so much server time? (A more performant solution) This approach adds ~500ms to initial server response time, effectively overriding the CDN. Commented Aug 4, 2020 at 9:38