如果标题不清楚,请道歉,基本上我有一个监听端口 80 的 Web 代理,我在 IIS 上设置了 URL 重写,(web.config 上的规则如下),它确实
http://example.com/api/blah/blah ->
http://example.com:8095/api/blah/blah
<rule name="api-example" enabled="true" patternSyntax="ECMAScript" stopProcessing="true">
<match url="^.*/api/.*$" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false" />
<action type="Rewrite" url="http://localhost:8095/{R:0}" appendQueryString="true" logRewrittenUrl="false" />
</rule>
它工作正常,没有问题,当我直接请求 localhost:8095 时也可以工作
但我也希望能够识别请求是直接请求还是通过 URL 重写模块。
我的想法是,将查询字符串附加到 URL 上,当 url 在 IIS 上被重写时,我可以检查查询字符串是否存在,如果不存在,则通过 URL 重写,那么这是直接请求
例子:
http://example.com/api/blah/blah?from=proxy -> http://example.com:8095/api/blah/blah?from=proxy
http://example.com/api/blah/blah?existing_query_string=blah&from=proxy -> http://example.com:8095/api/blah/blah?existing_query_string=blah&from=proxy
我怎样才能做到这一点?还是有其他方法可以做到这一点?
非常感谢
明