我試圖使用Tuckey的urlRewriteFilter重寫任何網址爲https://,同時保留任何追加到URL的查詢字符串參數。我urlrewrite.xml文件目前看起來像Tuckey urlRewriteFilter use-query-string =「true」不工作?
<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>
我認爲使用查詢字符串= 「真」 將做到這一點,所以
http://server.com/test.jsp?company=3&id=1
將被改寫,以
https://server.com/test.jsp?company=3&id=1
但這似乎沒有發生。什麼情況是,
http://server.com/test.jsp?company=3&id=1
被改寫爲
難道我做錯了什麼?感謝您的任何建議。
「qsappend」屬性僅在版本4.0中有效。 3.2中不存在。 比較http://www.tuckey.org/res/dtds/urlrewrite4.0.dtd – 2012-10-02 15:43:47
3.2的替代選擇是什麼? – gunnx 2015-01-29 16:35:55
更新了答案。日Thnx。 – vtor 2015-02-19 14:39:09