无法获取 URL 中的 IIS URL 重写句柄 %3F
我正在使用 URL 重写将对 ci.pl 的所有请求发送到我创建的代理(请求有 ci.pl,然后重定向到:/proxy/handler.ashx;附加查询字符串:yes)。效果很好。显然有一个非常旧的客户端应用程序发送以下请求: http:// webserver.com/ci.pl%3F4+505000+0+0+5
何时发送:http://myserver.com/ci.pl?4+505000+0+0 +5
最终发生的情况是 ci.pl 规则重定向到代理,但由于 ? 被接收为 %3F< /strong> 中不包含任何参数重定向。
我无法更新旧版客户端应用程序,因此我一直在尝试提出一个 URL 重写规则来检测 %3F + 将字符串传递到 % 右侧3F。有没有人做过类似的事情?
这是一个接近的配置,但 %3F 右侧的字符串未传递给代理。
<rewrite>
<rules>
<clear />
<rule name="Handle %3F" enabled="true" patternSyntax="Wildcard" stopProcessing="true">
<match url="*" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{QUERY_STRING}" pattern="*ci.pl%3F*" />
</conditions>
<action type="Redirect" url="/proxy/handler.ashx?{C:2}" appendQueryString="false" />
</rule>
<rule name="Detect CI.PL">
<match url="(.*)" />
<conditions>
<add input="{PATH_INFO}" pattern="ci.pl" />
</conditions>
<action type="Rewrite" url="/proxy/handler.ashx" />
</rule>
</rules>
</rewrite>
I'm using URL Rewrite to send all requests for ci.pl to a proxy I created (request has ci.pl then redirect to: /proxy/handler.ashx; append query string: yes). Works great. Apparently there's a really old client app that sending the following requests: http://webserver.com/ci.pl%3F4+505000+0+0+5
When it should be sending: http://myserver.com/ci.pl?4+505000+0+0+5
What ends up happening is that the ci.pl rule is redirecting to the proxy, but since the ? is recieved as %3F no parameters are included in the redirect.
I can't update the legacy client app, so I've been trying to come up with a URL Rewrite rule to detect the %3F + pass along the string to the right of the %3F. Has anyone out there done something similar?
Here's a config that's close, but the string to the right of the %3F is not being passed to the proxy.
<rewrite>
<rules>
<clear />
<rule name="Handle %3F" enabled="true" patternSyntax="Wildcard" stopProcessing="true">
<match url="*" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{QUERY_STRING}" pattern="*ci.pl%3F*" />
</conditions>
<action type="Redirect" url="/proxy/handler.ashx?{C:2}" appendQueryString="false" />
</rule>
<rule name="Detect CI.PL">
<match url="(.*)" />
<conditions>
<add input="{PATH_INFO}" pattern="ci.pl" />
</conditions>
<action type="Rewrite" url="/proxy/handler.ashx" />
</rule>
</rules>
</rewrite>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
以下内容对我有用:
匹配 URL
^ci\.pl(%3f|\?)(.*)
操作
这就是它的工作原理。上面的正则表达式以
ci.pl
开头,后跟%3f
或?
以及后面的任意字符序列。该序列被捕获,稍后可以称为{R:2}
(2 表示“从左侧开始的第二组括号”)。例如,如果 URI 为 http://webserver.com/ci。 pl%3F4+505000+0+0+5,则 {R:1} 和 {R:2} 将保存
%3F
并且分别4+505000+0+0+5
,产生结果http://myserver.com/ci.pl?4+505000+0+0+5 正如预期的那样。这是配置文件片段:
希望这有帮助。
The following worked for me:
Match URL
^ci\.pl(%3f|\?)(.*)
Action
This is how it works. The regex above mathes URIs starting with
ci.pl
followed by either%3f
or?
with a sequence of arbitrary characters after that. The sequence is captured and can be later referred to as{R:2}
(2 means "the second set of parenthesis starting from the left").For instance, if the URI is http://webserver.com/ci.pl%3F4+505000+0+0+5, then {R:1} and {R:2} will hold
%3F
and4+505000+0+0+5
respectively, producing the result http://myserver.com/ci.pl?4+505000+0+0+5 as expected.Here's the config file fragment:
Hope this helps.