After you configure a path rewriting rule, the path of an HTTP request can be rewritten to a specified value before being forwarded to the destination application. This topic describes how to configure a path rewriting rule.
Prerequisites
The preparations are completed, and the HTTPBin and sleep services are deployed. For more information, see Preparations.
Procedure
Configure a virtual service for the HTTPBin service to rewrite the path to
/status/400if the path in a request destined for the HTTPBin service is/get.Log on to the ASM console. In the left-side navigation pane, choose .
On the Mesh Management page, click the name of the ASM instance. In the left-side navigation pane, choose . On the page that appears, click Create.
On the Create page, configure the following parameters, and click Preview. Confirm that the YAML content is correct, click Submit, and then click Create.

The YAML preview is as follows.
apiVersion: networking.istio.io/v1beta1 kind: VirtualService metadata: name: httpbin namespace: default spec: hosts: - httpbin.default.svc.cluster.local http: - rewrite: uri: /status/400 route: - destination: host: httpbin.default.svc.cluster.local
Use kubectl to connect to the Container Service for Kubernetes (ACK) cluster based on the information in the kubeconfig file, and then run the following command to check whether the path rewriting configuration takes effect:
kubectl exec -it deploy/sleep -- curl httpbin:8000/get -IExpected output:
HTTP/1.1 400 Bad Request server: envoy date: xxx, xx xxx 202x xx:xx:xx GMT content-type: text/html; charset=utf-8 access-control-allow-origin: * access-control-allow-credentials: true content-length: 0 x-envoy-upstream-service-time: 4You can see that a request is sent to the
/getpath of the HTTPBin service in the sleep container. Requests sent to this path should be responded with the status code 200. However, in this case, the status code 400 is returned. The output indicates that the path rewriting configuration takes effect and the path of the request is rewritten to/status/400.