tuckey urlrewrite 3.x的問題

昨天晚上配置myblog的rewrite。發現一個奇怪的問題。由於現在使用的這個pjblog,爲了讓搜索引擎收錄的連接有效。我想把原來的asp連接rewrite到我的新程序上面。所以有這樣一條規則。

    <rule>
        
<from>^/article.asp\?id=(.*)$</from>
        
<to type="redirect">/entry/$1.jhtml</to>
    
</rule>
     但是我這樣的連接總是匹配不到,只要去掉那個?就可以了。這個正則表達式是沒有問題的。/article.asp?id=64是可以匹配的到的。
    後來看3.0的manual (http://tuckey.org/urlrewrite/manual/3.0/)才發現原來是這個的問題。

<urlrewrite> element

The top level element.

AttributePossible ValueExplanation
default-match-type
(optional)
regex (default)All rules and thier conditions will be processed using the Java Regular Expression engine (unless match-type is specified on a rule).
wildcardAll rules and thier conditions will be processed using the Wildcard Expression engine (unless match-type is specified on a rule).
decode-using
(optional)
utf8 (default)When URL is decoded UTF-8 will be used.
nullDo not decode.
[encoding]Any string representing a supported character encoding eg, ISO-8859-1. See Java Charset Object for more info.
use-query-string
(optional)
false (default)The query string will not be appended to the url that the "from" element matches against.
trueThe query string will be appended to the url that the "from" element matches against.
use-context
(optional)
false (default)The context path will not be added to the url that the "from" element matches against.
trueThe context path will be added to the url that the "from" element matches against.

就是那個use-query-string 的問題,默認的是不使用query-string就是把?後面的都忽略了。所以就不能匹配到了。只要在<urlrewrite>裏面加一個屬性就可以了。
<urlrewrite use-query-string="true">
    
</urlrewrite>

創造共用協議:署名,非商業,保持一致   除經特別註明外,本文章版權歸莫多泡泡所有.
署名,非商業用途,保持一致.   somebody(莫多)

87151.html

莫多 2006-12-12 10:33 發表評論
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章