Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

How can i redirect traffic in my URL map configuration

 

I have the following:

http://34.117.1.48

http://34.117.1.48/images/

[Query] How can i redirect all requests from http://34.117.1.48/images/<anything> to http://34.117.1.48/images/three-cats.jpg

 

Presently, my path rules are as follows:

 

defaultService: projects/test-case2-b/global/backendServices/cross-ref-backend-service
name: test-path-matcher
pathRules:
- paths:
  - /images/*
  service: projects/test-case2-b/global/backendBuckets/cross-ref-backend-bucket
 
Now, i guess i need to use route rules:
But how do i go about setting it up. 

Any pointers would be helpful.

Thank you!

0 2 242
2 REPLIES 2

Hi @mountaincode2 !

To redirect all request from /images/* you should go to your LB configuration -> Host and path rules, select Advanced host and path rule (URL redirect)

There define you host/s and define a new path rule. There put /images/* as your path, under action select "Redirect the client to a different host/path", in Path Redirect select "Full path redirect", input here /images/three-cats.jpg
This configuration will replace everything after /images (even the path itself) and replace it with the desired path.

Depending on the status of this change select the Response Code that is more according to your case.

 

Hope this helps!

@FrancoGP 

Thank you for the pointer.

If i were to do this, would it affect my earlier configuration. 

Also i cannot set it in the Console using the instructions you provided.

The docs say the following:

You can specify one of the following route actions:

- Route traffic to a single service (service).

- Split traffic between multiple services (weightedBackendServices weight:x, where x must be from 0 to 1000).

- Redirect URLs (urlRedirect).

Does it mean that i cannot redirect urls if iam splitting the traffic between the backend service and the backend bucket?