AWS S3 Redirect 添加尾部斜杠并将 & 编码为 &
AWS S3 Redirect adding trailing slashes and encoding & as &
我想做的是使用 S3 存储桶通过 "Static Web Hosting redirect requests".
执行 http 重定向
我尝试重定向到的目标存储桶或域是:"example.com/test?param1=123¶m2=456",协议是 "https"。
当我使用这个设置并点击我的桶时,它最终将我重定向到:
https://example.com/test?param1=123¶m2=456/
有其他人解决过这个问题吗?
看到了同样的情况,不想做 html/js 重定向 - 这是我所做的:
将存储桶更改为"use this bucket to host a website",将index.html作为索引文件但不添加实际文件,然后在路由规则中将其替换为&
;
<RoutingRules>
<RoutingRule>
<Redirect>
<Protocol>https</Protocol>
<HostName>example.com</HostName>
<ReplaceKeyWith>/test?param1=123&param2=456</ReplaceKeyWith>
</Redirect>
</RoutingRule>
</RoutingRules>
本质上,由于没有指定实际的路由规则,这会将所有流量重新路由到您想要的位置。保存时,& 将转换为 &,并且不会在末尾添加尾部斜杠。
谢谢,@Ryan,这对我有用。但是,AWS 现在要求在 JSON 中编写重定向规则,因此这是对@Ryan 的回答的更新。 (这里是关于重定向规则的 AWS documentation。)
[
{
"Redirect": {
"HostName": "yourdomain.com",
"Protocol": "https",
"ReplaceKeyWith": "/desired/path?with=query"
}
}
]
我想做的是使用 S3 存储桶通过 "Static Web Hosting redirect requests".
执行 http 重定向我尝试重定向到的目标存储桶或域是:"example.com/test?param1=123¶m2=456",协议是 "https"。
当我使用这个设置并点击我的桶时,它最终将我重定向到: https://example.com/test?param1=123¶m2=456/
有其他人解决过这个问题吗?
看到了同样的情况,不想做 html/js 重定向 - 这是我所做的:
将存储桶更改为"use this bucket to host a website",将index.html作为索引文件但不添加实际文件,然后在路由规则中将其替换为&
;
<RoutingRules>
<RoutingRule>
<Redirect>
<Protocol>https</Protocol>
<HostName>example.com</HostName>
<ReplaceKeyWith>/test?param1=123&param2=456</ReplaceKeyWith>
</Redirect>
</RoutingRule>
</RoutingRules>
本质上,由于没有指定实际的路由规则,这会将所有流量重新路由到您想要的位置。保存时,& 将转换为 &,并且不会在末尾添加尾部斜杠。
谢谢,@Ryan,这对我有用。但是,AWS 现在要求在 JSON 中编写重定向规则,因此这是对@Ryan 的回答的更新。 (这里是关于重定向规则的 AWS documentation。)
[
{
"Redirect": {
"HostName": "yourdomain.com",
"Protocol": "https",
"ReplaceKeyWith": "/desired/path?with=query"
}
}
]