I want to redirect all paths matching /#/signin
to a different URL using AWS Application Load Balancer’s listener rules for path based routing. However, AWS declares this path as invalid as it contains the character #
. Is there a way to acheive routing for such paths using AWS ALB?
Note – modifying the path is not an option.
2
Answers
I believe you cannot do redirects like that purely with ALB.
You can, however, target a Lambda and that lambda could do any custom routing logic you want. True, this approach is not the best.
It feels better to catch this issue before the ALB, like using CloudFront functions:
https://aws.amazon.com/blogs/aws/introducing-cloudfront-functions-run-your-code-at-the-edge-with-low-latency-at-any-scale/
It would be pretty typical usage for this feature.
You could also look at API gateways, but I’m not entirely sure it would be easier to use.
If we are moving away from AWS space, these redirections could be made with DNS as well. If you are using i.e.: Cloudflare before your AWS resources, it could be done with that as well:
https://developers.cloudflare.com/support/page-rules/configuring-url-forwarding-or-redirects-with-page-rules/
You won’t be able to redirect that path with any AWS technology, or any sever-side technology at all, because anything after a
#
in a URL is a "fragment" which is never sent to the server.When you load the URL
https://example.com/#/signin
in a browser, the browser splits it into several parts: