Search code examples
amazon-web-servicesamazon-s3amazon-cloudfrontamazon-route53amazon-elb

How to redirect domain to domain path using Cloudfront or Route 53?


I have an S3 bucket that serves static HTML in /id and /en

For example, I have domain https://www.myblog.com, I want to redirect to https://www.myblog.com/en or https://www.myblog.com/id based on client geolocation

Is there any way to achieve this with CloudFront OR Route 53?

thanks


Solution

  • Serverless approach:

    Attach a lambda@edge to the CloudFront distribution. In the lambda@edge, check the geolocation of the client IP and return 301 redirect accordingly.

    Non-serverless approach:

    Spin up two public EC2's (say A and B). Configure A and B to redirect traffic to /id and /en respectively. Then make a Route 53 geolocation routing to those two instances.

    If anyone has any better approaches, please let me know in the comment.