昨天晚上配置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</urlrewrite>
The top level element.
Attribute
Possible Value
Explanation
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). |
wildcard |
All 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. |
null |
Do 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. |
true |
The 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. |
true |
The context path will be added to the url that the "from" element matches against. |
就是那个use-query-string 的问题,默认的是不使用query-string就是把?后面的都忽略了。所以就不能匹配到了。只要在<urlrewrite>里面加一个属性就可以了。
</urlrewrite>
<urlrewrite use-query-string="true">
<!---->urlrewrite>
分享到:
相关推荐
在网上找了很多都不合心意,就知道改了下源码,只改了org.tuckey.web.filters.urlrewrite.UrlRewriteFilter.class 文件,如果担心安全的朋友,可以下载 4.0.3的jar 替换UrlRewriteFilter.class即可。 confPath 默认 ...
jar包,官方版本,自测可用
Servlet和过滤器库,具有tk-filters和tuckey.org的urlrewrite。 还包括名为HttpVariablesFilter的过滤器-对于使用displaytag表的排序/分页的大型表单很有用。
Tuckey.org URLRewriteFilter配置 JavaServer Faces(JSF) JavaServer页面(JSP) Struts 便门 ils子 春Ro Spring Web Flow 任何Servlet和Web框架! 所有主要的Servlet容器和应用程序服务器 得到帮助 支持论坛...
例程显示中间蝶形阶段的输出
Makumba项目 Java Web应用程序的bluepring。 它基于Servlet,Tuckey重写过滤器,Freemarker模板引擎,spock&gib测试框架。 设置属性