You can use path rules to direct requests to /blog to one backend service and requests to /shop to another. For example, a path rule might look like this:
If you want to route requests based on more than just the path, like a specific header or query parameter, you would use route rules. For example, you could route requests with a specific header to a different backend:
In this example, requests to /shop with the header X-User-Type: premium go to the premium-shop-backend, while all other /shop requests go to the regular-shop-backend.
“Path rules(pathRules) specify one or more URL paths, such as / or /video. Path rules are generally intended for the type of simple host and path-based routing”
“Route rule(routeRules) matches information in an incoming request and makes a routing decision based on the match.”
For a more detailed explanation of what are the differences between the two, please see the documentations below:
When you use path rules in a path matcher, you cannot create more than one path rule for the same path. For example, requests for /videos/hd cannot be directed to more than one backend service or backend bucket. Backend services can have backend instance groups or backend network endpoint groups (NEGs) in different zones and regions, and you can create backend buckets that use Multi-Regional Storage classes.
To direct traffic for a unique URL to multiple services, you can use route rules instead of path rules. If you configure the path matcher with route rules for header or parameter matches, a unique URL can be directed to more than one backend service or bucket, based on the contents of headers or query parameters on the URL.