无法获取 URL 中的 IIS URL 重写句柄 %3F

发布于 2025-01-01 07:37:15 字数 1551 浏览 1 评论 0原文

我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

想你的星星会说话 2025-01-08 07:37:15

以下内容对我有用:

匹配 URL

  • 请求的 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 正如预期的那样。

这是配置文件片段:

<rewrite>
    <rules>
        <rule name="ci" stopProcessing="true">
            <match url="^ci\.pl(%3f|\?)(.*)" />
            <action type="Redirect" url="http://myserver.com/ci.pl?{R:2}" appendQueryString="false" />
        </rule>
    </rules>
</rewrite>

希望这有帮助。

The following worked for me:

Match URL

  • Requested URL: Matches the Pattern
  • Using: Regular Expressions
  • Pattern: ^ci\.pl(%3f|\?)(.*)
  • Ignore case: Yes

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 and 4+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:

<rewrite>
    <rules>
        <rule name="ci" stopProcessing="true">
            <match url="^ci\.pl(%3f|\?)(.*)" />
            <action type="Redirect" url="http://myserver.com/ci.pl?{R:2}" appendQueryString="false" />
        </rule>
    </rules>
</rewrite>

Hope this helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文