[英]IIS rewrite rule not matching — setting up reverse proxy
This seems to be like the simplest of thing which I am unable to resolve. 这似乎是我无法解决的最简单的事情。
I want to rewrite URL if it contains the string extFlow , to a different host. 我想将包含字符串extFlow的 URL重写到其他主机。
http://site1/extFlow/Testsvc/GetData/?val=1
to 至
http://site2/extFlow/Testsvc/GetData/?val=1
I have tried all rules eg: 我尝试了所有规则,例如:
<rules>
<rule name="Reverse Proxy to external" stopProcessing="true">
<match url="extFlow/(.*)" />
<action type="Rewrite" url="http://site2/{R:1}" />
</rule>
</rules>
If I just match with (.*) then the rewrite happens. 如果我只与(。*)匹配,则会发生重写。
I am not able to match even with * match url="extFlow" 即使使用* match url =“ extFlow”,我也无法匹配
What am I missing? 我想念什么?
Based on your statement "Yes for testing purpose I have both sites on same machine, but on a different port", I think that's what is breaking your rule. 根据您的陈述“是的,为了测试目的,我将两个站点都放在同一台机器上,但是在不同的端口上”,我认为这是违反您的规则的原因。 Let me disintegrate and explain it. 让我分解并解释它。
Observe how you have "extFlow" in both your URL's. 观察两个URL中都有“ extFlow”。
Let's assume a request came in for 假设有一个请求
" http://site1/extFlow/Testsvc/GetData/?val=1 ". “ http:// site1 / extFlow / Testsvc / GetData /?val = 1 ”。 The URL rewrite rule URL重写规则
is hit and its rewrites it to 被击中并将其重写为
" http://site2/extFlow/Testsvc/GetData/?val=1 ". “ http:// site2 / extFlow / Testsvc / GetData /?val = 1 ”。
Since this new URL also hits the same machine and even it has 由于此新网址还会在同一台计算机上运行,甚至具有
"extFlow" in it, the rule will be triggered once again and again and again. 在它的“ extFlow”中,规则将一次又一次地被触发。
So indirectly you are triggering an indefinite loop here. 因此,您间接地在这里触发了无限循环。
Let me know if you have any questions. 如果您有任何疑问,请告诉我。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.