How do I fix this 403 when redirecting www traffic to non-www?

0

I have an S3 website with route-53 and cloudfront. I'm really happy with it.

I've edited the default cloudfront behaviour to redirect http to https and has a function on Viewer Request that rewrites - this looks fine when testing it in the web UI.

however, whenever I go to www. in a browser I get a 403 (either http or https)

It's doing my head in!

1 Answer
2
Accepted Answer

Hello.

Are you configuring domains with and without "www" in the settings in the CloudFront document below?
I think that if this was not set, an error would occur when accessing with a domain without "www".
Try verifying that the alternate domain is configured successfully.
https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/CreatingCNAME.html
https://repost.aws/knowledge-center/cloudfront-troubleshoot-403-errors

profile picture
EXPERT
answered a month ago
profile picture
EXPERT
reviewed a month ago
profile picture
EXPERT
reviewed a month ago
  • Oh my goodness Riku that was it! You are officially better than the AI that was helping me :) although it did give some other good advice...

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.

Guidelines for Answering Questions