将子域 URL 重定向到 Amazon AWS 上的 URL 子目录

编程入门 行业动态 更新时间:2024-10-25 16:28:39
本文介绍了将子域 URL 重定向到 Amazon AWS 上的 URL 子目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我们通过 AWS 上的 Route 53 创建了一个指向外部服务器的子域.我们现在想将该流量重定向回主域,但重定向到子目录.

We've created a subdomain via Route 53 on AWS that points to an external server. We now want to redirect that traffic back to the main domain, but to a subdirectory.

shop.mydomain 将重定向到 mydomain/shop

shop.mydomain would redirect to mydomain/shop

DNS 不喜欢那样解析子目录...有什么建议吗?

DNS doesn't like resolving subdirectories like that... any suggestions?

推荐答案

如果我理解正确,您希望对 shop.mydomain 的所有请求重定向到 mydomain/shop.

If I understand correctly, you want ALL requests to shop.mydomain to redirect to mydomain/shop.

在这种情况下,我建议使用 S3 的重定向规则".

In that case I recommend using S3's "Redirection Rules".

在 S3 中创建一个名为 shop.mydomain 的存储桶.打开存储桶属性并将存储桶设置为启用网站托管".然后选择编辑重定向规则"选项.

Create a bucket in S3 called shop.mydomain. Open the bucket properties and set the bucket to "Enable Website Hosting". Then select the "Edit Redirection Rules" option.

我们现在需要定义一个匹配每个请求的重定向规则,并将其重定向到mydomain/shop

We now need to define a redirection rule that matches every request, and redirects it to mydomain/shop

<RoutingRules> <RoutingRule> <Redirect> <Protocol>https</Protocol> <HostName>mydomain</HostName> <ReplaceKeyPrefixWith>shop/</ReplaceKeyPrefixWith> <HttpRedirectCode>301</HttpRedirectCode> </Redirect> </RoutingRule> </RoutingRules>

此规则将匹配每个请求并将其重定向.

This rule will match every request and redirect it.

有关路由规则的更多信息,请查看官方文档:docs.aws.amazon/AmazonS3/latest/dev/HowDoIWebsiteConfiguration.html#configure-bucket-as-website-routing-rule-syntax

For more info on routing rules, check out the official docs: docs.aws.amazon/AmazonS3/latest/dev/HowDoIWebsiteConfiguration.html#configure-bucket-as-website-routing-rule-syntax

现在,您需要在 Amazon Route 53 中将 shop.mydomain 配置为指向您刚刚创建的存储桶 shop.mydomain 的 ALIAS 记录.

Now, you need to configure shop.mydomain in Amazon Route 53 as an ALIAS record pointing at the bucket you just created, shop.mydomain.

就是这样 - 享受吧!

That's it - Enjoy!

更多推荐

将子域 URL 重定向到 Amazon AWS 上的 URL 子目录

本文发布于:2023-11-01 23:26:49,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1550713.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:子目录   重定向   URL   将子域   Amazon

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!