URL 重写过滤器不适用于包含特殊字符的查询参数

2023-12-24

我正在使用 URL 重写过滤器将一些丑陋的 URL 转发到漂亮的 URL。 参考基于 URL 参数的条件 http://devtidbits.com/2011/11/28/tuckey-urlrewrite-how-to/, 我使用 UrlRewriteFilter 做了一些事情,这实际上是使我的网站可供 Google 抓取所必需的。 事情是这样的。

<rule enabled="true">
        <note>
            The rule means that requests to /test/status/ will be redirected to /rewrite-status
            the url will be rewritten.
        </note>
        <condition type="parameter" name="_escaped_fragment_" operator="equal">(apple|kiwi|orange)</condition>
            <from>^/mysite/(.+)/(.*)$</from>
            <to type="redirect">/mysite/%{parameter:_escaped_fragment_}</to>
    </rule>

它无法抛出 java.lang.IllegalArgumentException: URLDecoder: 转义 (%) 模式中的非法十六进制字符 – %%7。 由于我的变量包含下划线(_escaped_fragment_),因此它可以与名为“friuit”的参数变量配合使用。 请帮助我摆脱困境。


<rule>
<condition name="_escaped_fragment_" type="parameter" operator="equal">(apple|kiwi|orange)</condition>
<to type="redirect">/mysite/%1</to>
</rule>

使用查询参数的值%{parameter:_escaped_fragment_}仅适用于不包含特殊字符的单词。在哪里%1(即 % 后跟查询参数索引)适用于任何,这解决了我的问题。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

URL 重写过滤器不适用于包含特殊字符的查询参数 的相关文章

随机推荐