Is there a way to rewrite the url to the root in the gateway? Like this:
- match:
- uri:
prefix: "/withdrawal"
rewrite:
uri: ""
Is there a way to rewrite the url to the root in the gateway? Like this:
- match:
- uri:
prefix: "/withdrawal"
rewrite:
uri: ""
Request routing done in VirtualService not gateway.
If you looking for something to be done at ingress. Can take look at envoy filter.
Hi @prabhu_mannu and @Rodrigo_Valladares,
Given that the rewrite should be in the VirtualService, I haven’t found a way to rewrite to the root uri as Rodrigo demonstrates in his question. For example, a common use case would be if you want to want to rewrite all traffic from a given path to the root of the backend service. The rewrite always adds an extra slash at the beginning of the path on the destination.
For example, say I have a VirtualService that has the following match and rewrite:
- match:
- uri:
prefix: "/withdrawal"
rewrite:
uri: /
What I want to happen is as follows (where myservice is the backend service name):
example.com/withdrawal -> my_k8s_service
example.com/withdrawal/something/ -> my_k8s_service/something
But what I end up seeing is (note the double slash that istio added):
example.com/withdrawal -> my_k8s_service
example.com/withdrawal/something/ -> my_k8s_service//something
I can’t add an empty string
I opened up a stackoverflow question about this as well, as the Istio community guidelines suggest both places for istio help.
Is it possible to rewrite to the root url in istio?
hi
i had on issue rewriting the URL like this
i have two rules
first rule
- match:
- uri:
prefix: /public/api/v1/
rewrite:
uri: /api/v1/
headers:
request:
add:
endpoint: pubilc
response:
add:
endpoint: pubilc
route:
second rule
- match:
- uri:
prefix: /
headers:
request:
add:
endpoint: internal
response:
add:
endpoint: internal
maybe try this. I don’t have any issue with double slash, not that i noticed it
Thank you @prabhu-mannu, I think my issue is that I was not adding a trailing slash to the end of my prefix.
When I changed it to look like this, I didn’t see the double slash issue.
- match:
- uri:
prefix: "/withdrawal/"
rewrite:
uri: /
I am glad that your problem is solved.