URL 根据请求参数转发
URL Forwarding based on request parameters
我正在使用 http://www.tuckey.org/urlrewrite/. Mainly I am trying to get the following URL
http://domain/application/?param=value to redirect to
http://domain/application/?another_param=another_value 的 UrlRewriteFilter(只是替换请求参数)。
以下是我的规则配置,但似乎不起作用
<rule>
<from>^(.*?param=value)$</from>
<to type="forward">%{context-path}?another_param=another value</to>
</rule>
我尝试了其他几种变体,但似乎也没有用。任何关于这个问题的线索都将不胜感激
我已经能够使用以下规则解决问题
<rule>
<name>Selective redirect example redirect</name>
<condition type="parameter" name="param" operator="equal">value</condition>
<to type="forward">?another_param=another_value</to>
</rule>
这里答案的关键是使用条件而不是依赖规则来捕获请求,在我的例子中,我只需要在满足某个参数值时应用规则。答案的第二部分是删除 <from>
标签,因此所有满足条件的请求将被重定向到相同的源页面。
最后,以下是对我搜索答案最有用的链接:
- URLRewriteFilter Examples page
- The Developer's Tidbits: Tuckey URLRewrite How-To
- Whosebug post: URL Rewrite Filter not working with query parameters containing special characters
我正在使用 http://www.tuckey.org/urlrewrite/. Mainly I am trying to get the following URL
http://domain/application/?param=value to redirect to
http://domain/application/?another_param=another_value 的 UrlRewriteFilter(只是替换请求参数)。
以下是我的规则配置,但似乎不起作用
<rule>
<from>^(.*?param=value)$</from>
<to type="forward">%{context-path}?another_param=another value</to>
</rule>
我尝试了其他几种变体,但似乎也没有用。任何关于这个问题的线索都将不胜感激
我已经能够使用以下规则解决问题
<rule>
<name>Selective redirect example redirect</name>
<condition type="parameter" name="param" operator="equal">value</condition>
<to type="forward">?another_param=another_value</to>
</rule>
这里答案的关键是使用条件而不是依赖规则来捕获请求,在我的例子中,我只需要在满足某个参数值时应用规则。答案的第二部分是删除 <from>
标签,因此所有满足条件的请求将被重定向到相同的源页面。
最后,以下是对我搜索答案最有用的链接:
- URLRewriteFilter Examples page
- The Developer's Tidbits: Tuckey URLRewrite How-To
- Whosebug post: URL Rewrite Filter not working with query parameters containing special characters