[英]What causes Tuckey's UrlRewriteFilter to malform urlencoded unicode characters (e.g. %C3%B6 for ö) and how can I avoid it?
我們正在使用一個簡單的UrlRewriteFilter規則來永久(301)重定向HTTP請求, 而不會在斜杠后面加上斜杠到相同的URL。
在某些情況下,我們的表示層需要在其中包含編碼特殊字符的URL(例如ö的%C3%B6),只要不涉及UrlRewriteFilter,它就可以正常工作。 但是當規則生效時,我可以看到重定向時編碼的字符格式錯誤,例如
www.mydomain.com/asdf%C3%B6asdf/
/-> www.mydomain.com/asdf%F6asdf/
> www.mydomain.com/asdf%F6asdf/
%F6
不是有效的unicode序列(經url解碼后,以黑色菱形結尾為問號)。
我們在整個應用程序中使用UTF-8,它在響應標頭以及HTML的<head>
部分中進行設置。 格式錯誤的編碼發生在Windows和Linux計算機上。 重寫規則如下所示
<rule enabled="true" match-type="regex" >
<name>Force trailing slash</name>
<note>...</note>
<condition type="request-uri" operator="notequal">...>/condition> <!-- some URLs shall not be redirected -->
<from>(^[^\?]*)(\?.*)?$</from>
<to type="permanent-redirect" last="true" >$1/$2</to> <!-- adding trailing slash and query string, if present -->
</rule>
我很高興有任何想法可以解決這個問題。 我玩過decode-using
和encode
屬性,但沒有幫助。
我有一個類似的問題。 我所做的是將解碼設置為null:
<urlrewrite decode-using="null">
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.