How to manage URL rewrites with a GCP load balancer?

We have a single-page web application deployed on a GCP bucket with a load balancer in front of it.
All URLs such as example.com/login should be rewritten as example.com/#/login. Without being rewritten the default behaviour is to go fetch some login.html but we only have and need index.html, the application handles the routing.

How to configure the load-balancer to achieve such a task?


Redirection on LB level is currently not possible on GCP. You may refer to this where some of the users have recommendations on how to redirect within the app. If this doesn’t help, you may file a feature request with the load balancing component using the Google issue-tracking tool.


Google LB is capable of:

  • URL redirect
  • URL rewrite

since the summer 2020: https://cloud.google.com/load-balancing/docs/https/setting-up-traffic-management

Official blog announcement: https://cloud.google.com/blog/products/networking/how-to-use-new-traffic-control-features-in-cloud-load-balancing