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">
精彩评论