简体   繁体   English

如何使用Tuckey urlrewrite重命名参数?

[英]How do I rename a parameter with Tuckey urlrewrite?

I'm using the Tuckey urlrewrite filter with use-query-string set to the default (false). 我正在使用Tuckey urlrewrite过滤器,并将use-query-string设置为默认值(false)。 This means that the from urls don't use the query parameters to match. 这意味着from urls不使用查询参数进行匹配。 What I'd like to do in an isolated case is rename one query parameter, which would require matching the query-string in the from tag. 我想在一个孤立的情况下做的是重命名一个查询参数,这需要匹配from标签中的查询字符串。

For example, I would like to do this: 例如,我想这样做:

<rule>
    <from>^/myPage?id=(.*)$</from>
    <to>/newPage?userId=$1</to>
</rule>

This is possible with use-query-string=true , unfortunately that would be a global change and there are many rules which would break if I change this setting. 这可以使用use-query-string=true ,遗憾的是,这将是一个全局变化,如果我更改此设置,有许多规则会中断。

Is there a way to override use-query-string for a single rule? 有没有办法覆盖单个规则的use-query-string

Is there a work around? 有工作吗?

I found a hint to the answer on this unanswered question. 我找到了一个关于这个悬而未决的问题答案的暗示。 You can use the 'backreferences' functionality, as described in the manual (although its not very clear how it works) 您可以使用“反向引用”功能,如手册中所述(尽管不太清楚它是如何工作的)

<rule>
    <from>^/mypage$</from>
    <to type="redirect" >/newPage?userId=%{parameter:id}</to>
</rule>  

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM