子域名重定向到URL在亚马逊AWS URL子目录 [英] Redirect subdomain URL to URL subdirectory on Amazon AWS
问题描述
我们已经创建了通过路线53的子域在AWS上指向外部服务器。我们现在想的流量重定向到主域名,而是一个子目录。
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.com会重定向到mydomain.com/shop~~V
shop.mydomain.com would redirect to mydomain.com/shop
DNS不喜欢解决这样的...有什么建议子目录?
DNS doesn't like resolving subdirectories like that... any suggestions?
推荐答案
如果我理解正确的话,你希望所有的请求 shop.mydomain.com
来重定向到 mydomain.com/shop
。
If I understand correctly, you want ALL requests to shop.mydomain.com
to redirect to mydomain.com/shop
.
在这种情况下,我建议使用S3的重定向规则。
In that case I recommend using S3's "Redirection Rules".
在创建S3水桶名为 shop.mydomain.com
。打开桶的属性,设置桶启用网站托管。然后选择编辑重定向规则选项。
Create a bucket in S3 called shop.mydomain.com
. Open the bucket properties and set the bucket to "Enable Website Hosting". Then select the "Edit Redirection Rules" option.
现在,我们需要定义一个重定向规则,每个请求匹配,并重定向到 mydomain.com/shop
We now need to define a redirection rule that matches every request, and redirects it to mydomain.com/shop
<RoutingRules>
<RoutingRule>
<Redirect>
<Protocol>https</Protocol>
<HostName>mydomain.com</HostName>
<ReplaceKeyPrefixWith>shop/</ReplaceKeyPrefixWith>
<HttpRedirectCode>301</HttpRedirectCode>
</Redirect>
</RoutingRule>
</RoutingRules>
此规则将匹配每一个请求,并将其重定向。
This rule will match every request and redirect it.
有关路由规则的详细信息,请查看官方文档:<一href="http://docs.aws.amazon.com/AmazonS3/latest/dev/HowDoIWebsiteConfiguration.html#configure-bucket-as-website-routing-rule-syntax">http://docs.aws.amazon.com/AmazonS3/latest/dev/HowDoIWebsiteConfiguration.html#configure-bucket-as-website-routing-rule-syntax
For more info on routing rules, check out the official docs: http://docs.aws.amazon.com/AmazonS3/latest/dev/HowDoIWebsiteConfiguration.html#configure-bucket-as-website-routing-rule-syntax
现在,您需要配置 shop.mydomain.com
亚马逊路线53为 ALIAS
记录指向刚创建的水桶, shop.mydomain.com
。
Now, you need to configure shop.mydomain.com
in Amazon Route 53 as an ALIAS
record pointing at the bucket you just created, shop.mydomain.com
.
这就是它 - 享受
这篇关于子域名重定向到URL在亚马逊AWS URL子目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!