I noticed the Amazon S3 redirection rule - there is no GET data , but after the accepted response, my request parameters are still not saved.
I have a website that uses React and React Router, that is, I have several URLs that load the same HTML and JS, and then JS determines which part of the application to load based on the URL.
For example:
/ foo, / bar, / baz should all load index.html, which loads bundle.js. Bundle.js then looks at the URL and routes any React component (also in bundle.js).
However, in S3 there is no foo, bar or baz file, but only index.html. What I want to do is when I get 404, redirect to / #! / {URL} (e.g.. / Foo redirect to / #! / Foo). This works fine with my redirection rule (below). However, I also want to bring request parameters with me (e.g. / foo? Ping = pong redirects to / #! / Foo? Ping = pong), but instead / foo? Ping = pong just redirects to / #! / Foo.
Here are my redirection rules:
<RoutingRules> <RoutingRule> <Condition> <HttpErrorCodeReturnedEquals>404</HttpErrorCodeReturnedEquals> </Condition> <Redirect> <Protocol>http</Protocol> <HostName>www.mydomain.com</HostName> <ReplaceKeyPrefixWith>#!/</ReplaceKeyPrefixWith> </Redirect> </RoutingRule> </RoutingRules>
Any ideas somehow I can achieve this? Ideally, without having to change anything in S3 / CloudFront every time I add a new page?
redirect amazon-s3 amazon-web-services amazon-cloudfront react-router
Andrew Rasmussen
source share