Reputation: 118
What I am trying to do is use an S3 bucket to perform http redirects via the "Static Web Hosting redirect requests".
The target bucket or domain that I'm trying to redirect to is: "example.com/test?param1=123¶m2=456" and the protocol is "https".
When I use this setup though and hit my bucket it ends up redirecting me to: https://example.com/test?param1=123¶m2=456/
Has anyone else worked through this?
Upvotes: 9
Views: 4232
Reputation: 185
Thanks, @Ryan, this worked for me. However, AWS now requires redirection rules to be written in JSON so here's an update to @Ryan's answer. (Here's AWS documentation on redirection rules.)
[
{
"Redirect": {
"HostName": "yourdomain.com",
"Protocol": "https",
"ReplaceKeyWith": "/desired/path?with=query"
}
}
]
Upvotes: 2
Reputation: 204
Have seen the same and didn't want to do an html/js redirect - here's what I did:
Change the bucket to "use this bucket to host a website", put index.html as the index document but don't add an actual file, then in routing rules put this, replacing ampersands with &
;
<RoutingRules>
<RoutingRule>
<Redirect>
<Protocol>https</Protocol>
<HostName>example.com</HostName>
<ReplaceKeyWith>/test?param1=123&param2=456</ReplaceKeyWith>
</Redirect>
</RoutingRule>
</RoutingRules>
Essentially, since no actual routing rule is specified this will reroute all traffic where you want. On save the & will be converted to & and no trailing slash will be added at the end.
Upvotes: 10