简体   繁体   中英

Urlrewrite rule doesn't capture question marks

Currently, I have 2 web services (ws1 and ws2) in the same web app (app1).

We've now decided to seperate the web services into different web apps: ws1 stays in app1, ws2 now goes in app2. However we don't want to change calling client code to be aware of the 2 apps. So clients keep calling /app1/ urls

So using Tuckey Urlrewritefilter I've set up this rule within app1 to rewrite any ws2 requests to app2:

<rule>
    <from>^/(ws2.*)$</from>
    <to type="redirect">/app2/$1</to>
</rule>

For example, /app1/ws2.get gets redirected to /app2/ws2.get. That's fine.

But requests to /app1/ws2?wsdl gets redirected to /app2/.

It doesn't appear to be a problem with the regular expression as I've tested that independently and it works.

Any idea why the question mark causes the capture to only contain 'ws2'?

I imagine that everything after the question mark is being interpreted as part of the query string, not the URL, so it is not captured in your from. If so, you'll want to append the query string to your redirect, like so:

<rule>
  <from>^/ws2$</from>
  <to type="redirect">/app2/?%{query-string}</to>
</rule>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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