【发布时间】:2020-10-08 01:43:28
【问题描述】:
请问如何改写网址
“https://hello.com/test/api/zoo/v1/animal?animal_record_no=20900016431”
到
“https://145.123.2.12:5000/api/zoo/v1/animal?animal_record_no=20900016431”
查询字符串“animal_record_no”是可选的。
基本上我只是想从 url 中删除“测试”并更改 ip 地址。
这是我现在拥有的,但它不转发查询字符串:
<rule name="ReverseProxyInboundRule3" stopProcessing="true">
<match url="^test/([_0-9a-zA-Z-]+)/([_0-9a-zA-Z-]+)/([_0-9a-zA-Z-]+)/([_0-9a-zA-Z-]+)/?$" />
<action type="Rewrite" url="http://145.123.2.12:5000/{R:1}/{R:2}/{R:3}/{R:4}" />
<conditions>
</conditions>
</rule>
如果我使用重定向,我会收到 HTTP/1.1 301 Moved Permanently 错误
<rule name="ReverseProxyInboundRule3" enabled="true" stopProcessing="true"> <match url=".*test/(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="iex.odp.gov.sg" />
</conditions>
<action type="Redirect" url="http://145.123.2.12:5000/{R:1}" />
感谢您的帮助。
【问题讨论】:
标签: iis url-rewriting