Getting the query string when using Tuckey URL Rew

2019-06-05 17:11发布

I have the following rule:

<rule>
     <from>^/users/(.*)$</from>
     <to last="true">/users.do$1</to>
</rule>

And I want to match the following url:

http://localhost:8077/users/?elemsPerPage=10

and redirect it to:

http://localhost:8077/users.do?elemsPerPage=10

The problem is that when the url rewriter engine finds the "?" character in the url it does not return anything else in the $1 matched parameter. Neither it adds the parameters to the query string. Any ideas?

2条回答
疯言疯语
2楼-- · 2019-06-05 17:46

Finally I've found a way to solve this:

Rule:

<rule>
     <from>^/users/$</from>
     <to last="true">/users.do?%{query-string}</to>
</rule>
查看更多
再贱就再见
3楼-- · 2019-06-05 17:56

There is a better way, try to add use-query-string="true" in urlrewrite

<urlrewrite use-query-string="true">

查看更多
登录 后发表回答