Hi list, I'm using RewriteRule to remove the query string. Using this very simple rule: RewriteRule /foo /bar? [R,L]
results in GET /foo?quux -> GET /bar? The redirect includes a spurious question mark, I expected it to be GET /foo?quux -> GET /bar (tested on tomcat 8.5.15) Looking at the code (java/org/apache/catalina/valves/rewrite/RewriteValve.java), It looks buggy: int index = urlStringDecoded.indexOf("?"); [..] snip [..] urlStringDecoded = urlStringDecoded.substring(0, index); urlStringEncoded = URLEncoder.DEFAULT.encode(urlStringDecoded, uriCharset) [..] snip [..] } else if (index == urlStringEncoded.length() - 1) { // if the ? is the last character delete it, its only purpose was to // prevent the rewrite module from appending the query string urlStringEncoded.deleteCharAt(index); } >From what I understand, the last block is dead code because urlStringEncoded is the substring of the original up to index *excluded*, so index can never been equal to urlStringEncoded.length() - 1 The code then proceeds and adds the spurious question mark to the result. Can anyone confirm this or did I miss something ? Cheers, Jon ps: The code is also wrong in comparing the index of '?' in the *decoded* string to the length of the *encoded* string, but that's another matter. Jon Jon