skip to Main Content

I want to redirect a url and their subdomains api.example.com/static/brands/* to www.example.com/brands/*. My goal is that when a client go in www.example.com/brands/* the webpage seen is the webpage of api.example.com/static/brands/* but the URL is www.example.com/brands/* so it’s totally transparent for him.

The domain name api.example.com is redirecting to an ALB.

I am a bit confused about what is the logic, how can I achieve this with Cloudfront?

2

Answers


  1. You can use CloudFront Functions (lightweight JavaScript functions that execute at the edge). Here is an example reference of doing redirects based on country – you can modify based on your needs: https://github.com/aws-samples/amazon-cloudfront-functions/tree/main/redirect-based-on-country

    Login or Signup to reply.
  2. I believe what you want is to make a cloudfront distrobution for www.example.com

    Which has an origin api.example.com/static/brands/

    and a pattern path /brands/* which redirects all requests from example.com/brands/* to the origin api.example.com/static/brands/

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search