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?
If you want the same TTL for the whole S3 bucket served via Cloudfront, including newly added files, then you can set this in Cloudfront. Go to Cloudfront in the AWS console, click on Behaviours, click the distribution from this bucket, and click edit.
Subresources. Amazon S3 uses the subresource mechanism to store object-specific additional information. Because subresources are subordinates to objects, they are always associated with some other entity such as an object or a bucket. For more information, see Object subresources. Access control information.
Short description. To redirect a domain in CloudFront, use one of the following: An Amazon Simple Storage Service (Amazon S3) website endpoint that returns a 301 status code. An edge function that redirects requests to the new domain.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With