如何使用CloudFront将所有URL子域重定向到其他URL子域?

发布于 2025-02-13 16:20:57 字数 364 浏览 1 评论 0原文

我想重定向URL及其子域api.example.com/static/brands/* www.example.com/brands/brands/*。我的目标是,当客户端进入www.example.com/brands/*所看到的网页是api.example.com/static/brand/brands/*的网页。但是URL是www.example.com/brands/*,因此对他来说是完全透明的。

域名api.example.com正在重定向到ALB。

我对什么是逻辑有些困惑,如何用云方实现这一目标?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

无悔心 2025-02-20 16:20:58

您可以使用CloudFront函数(在边缘执行的轻质JavaScript函数)。这是基于国家/地区进行重定向的示例参考 - 您可以根据自己的需求进行修改: https://github.com/aws-samples/amazon-cloudfront-functions/tree/main/main/redirect-lase--con-con-on-country

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

少跟Wǒ拽 2025-02-20 16:20:57

我相信您想要的是为www.example.com进行云额分散,

该>具有Origin api.example.com/static/brands/code>

和模式路径<代码>/brands/*将所有请求从example.com/brands/*重定向到原始api.example.com/static/brands/

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/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文