Search code examples
amazon-web-servicesproxyreverse-proxyamazon-cloudfront

How can I redirect all URLs subdomains to other URLs subdomains using Cloudfront?


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?


Solution

  • 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/