我们通过 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 子目录
发布评论