skip to Main Content

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


  1. 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/

    Login or Signup to reply.
  2. 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:

    • The scheme "https", which tells it the protocol to use, and the format of the rest of the URL
    • The hostname "example.com", which is used to look up an IP address to connect to, and then sent in the TLS handshake (SNI) and in the HTTP "Host:" header
    • The path "/" which is requested once the connection is established
    • The fragment "#/signin" which is used once the response is received to scroll to a matching anchor on the page, if one is found; and is then made available to JavaScript
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search