admin管理员组文章数量:1127072
How to remove a part of uri path in the azure APIM policy ?
Original Request follows a pattern: /***
Desired Url, without /preprod route in it,
ex: ,
<policies>
<inbound>
<base />
<choose>
<when condition="@(context.Request.OriginalUrl.Path.Contains("/preprod"))">
<set-backend-service backend-id="pub-lb-api-v1" />
<set-header name="Host" exists-action="override">
<value>test.abc</value>
</set-header>
</when>
....
</policies>
How to remove a part of uri path in the azure APIM policy ?
Original Request follows a pattern: https://apim.com/preprod/api/v1/***
Desired Url, without /preprod route in it,
ex: https://test.abc.com/api/v1/products,
https://test.abc.com/api/v1/order?xyz=1
<policies>
<inbound>
<base />
<choose>
<when condition="@(context.Request.OriginalUrl.Path.Contains("/preprod"))">
<set-backend-service backend-id="pub-lb-api-v1" />
<set-header name="Host" exists-action="override">
<value>test.abc.com</value>
</set-header>
</when>
....
</policies>
Share
Improve this question
edited Jan 8 at 20:05
userahd
asked Jan 8 at 19:22
userahduserahd
576 bronze badges
1
|
1 Answer
Reset to default 0You can use the below given policy to remove a part of Uri parameter.
<policies>
<inbound>
<base />
<choose>
<when condition="@(context.Request.OriginalUrl.Path.Contains("/preprod"))">
<rewrite-uri template="@((context.Request.OriginalUrl.Path).Replace("/preprod", ""))" />
<set-backend-service base-url="https://test.abc.com" />
<set-header name="Host" exists-action="override">
<value>test.abc.com</value>
</set-header>
</when>
</choose>
</inbound>
</policies>
This will remove the preprod from the Uri path and provide you the expected response.
本文标签: url rewritingremove a part of url in api management policiesStack Overflow
版权声明:本文标题:url rewriting - remove a part of url in api management policies - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736692400a1948003.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
<when>.... </set-header><find-and-replace from="preprod/api" to="api" /></when>
– userahd Commented Jan 8 at 20:09