I am trying to use Tuckey urlRewriteFilter to rewrite any URLs in https: //, while preserving any query string parameters that have been added to the URL. My urlrewrite.xml file currently looks like
<urlrewrite use-query-string="true"> <rule> <note> The rule means that requests to /test/status/ will be redirected to /rewrite-status the url will be rewritten. </note> <from>/test/status/</from> <to type="redirect">%{context-path}/rewrite-status</to> </rule> <rule match-type="regex"> <condition type="header" operator="notequal" name="X-Forwarded-Proto">^HTTPS$</condition> <condition type="request-uri" operator="notequal">/station/StationPingServlet</condition> <condition type="request-uri" operator="notequal">/station/StudioPingServlet</condition> <from>^.*$</from> <to type="permanent-redirect" last="true">https://%{server-name}%{request-uri}</to> </rule> <outbound-rule> <note> The outbound-rule specifies that when response.encodeURL is called (if you are using JSTL c:url) the url /rewrite-status will be rewritten to /test/status/. The above rule and this outbound-rule means that end users should never see the url /rewrite-status only /test/status/ both in thier location bar and in hyperlinks in your pages. </note> <from>/rewrite-status</from> <to>/test/status/</to> </outbound-rule>
I thought use-query-string = "true" would do this, so
http://server.com/test.jsp?company=3&id=1
will be rewritten to
https://server.com/test.jsp?company=3&id=1
but this does not seem to be happening. It happens that
http://server.com/test.jsp?company=3&id=1
corresponded as
https://server.com/test.jsp
Am I doing something wrong? Thanks for any advice.
source share