开发者

Regular expression for replace?

I am trying to replace relative url from /abc/bbc.do?count=1 with /bbc.do?count=1 using urlrewritefilter but when I am using the regular expression /abc/(.*)$ and redirect to /1$ it only seems to be capturing bbc.do and not url parameters. Any suggestions?

开发者_StackOverflow中文版
<rule match-type="regex">
    <from>^/abc/(.+)$</from>
    <to type="redirect">/$1</to>
</rule>


Update

It looks like the begin anchor is fine, but the backreferences use % instead of $. Solution is updated.

<rule match-type="regex">
    <from>^/abc/(.+)$</from>
    <to type="redirect">/%1</to>
</rule>

Also, make sure to add use-query-string="true" to your urlrewrite node. It is false by default.

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜