- Newest
- Most votes
- Most comments
CloudFront Functions fits better than Lambda@Edge.
Refer the below doc which mentions that Cloudfront Functions are ideal for URL redirects or rewrites
https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/edge-functions-choosing.html
answered 2 years ago
Hi,
The way to go to find a solution to your use case is to use Lambda@Edge with CloudfFront: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/lambda-at-the-edge.html
These articles may also be useful:
- https://dev.to/aws-builders/get-started-with-cloudfront-part-4-lambdaedge-function-4cbh
- https://medium.com/@nagarjun_nagesh/aws-lambda-edge-scenarios-for-cloudfront-distribution-369680c180c7
Best,
Didier
CloudFront Functions fits better than Lambda@Edge.
Refer the below doc which mentions that Cloudfront Functions are ideal for URL redirects or rewrites
https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/edge-functions-choosing.html
First of all, thank you very much for your reply.
I have tried with the Cloudfront function and when debugging I realised that as host I received cdn.example.es which is not useful for this case because it is necessary to know which exact domain it is so that it redirects/rewrites to its corresponding domain.
I hope I have clarified this. Once again, I would like to express my sincere gratitude for your assistance.
Best regards, Daniel
Relevant content
asked 2 years ago
- AWS OFFICIALUpdated a year ago

First of all, like the colleague in the other reply, I would like to thank you so much for the answer you have posted.
As I said in the other answer I already used the Cloudfront function with no successful result as I could not differentiate from which domain the user made the request as it always returned cdn.example.es as host.
I hope this helps.
Best regards, Daniel
I have used it to redirect when user enters xyz.app in browser and redirect to ex.abc.com and it works well. Probably you are checking the wrong field or something
None of the fields I print out from the entire request are useful. :(
@Dani, checkout this post, it has code example as well https://repost.aws/questions/QUhVdW_I-qSieyajqh-go6ZA/cloudfront-function-to-redirect-domain-to-other-url