<!-- Set URL Rewrite--> <filter> <filter-name>UrlRewriteFilter</filter-name> <filter-class> org.tuckey.web.filters.urlrewrite.UrlRewriteFilter </filter-class> </filter> <filter-mapping> <filter-name>UrlRewriteFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
过滤规则
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE urlrewrite PUBLIC "-//tuckey.org//DTD UrlRewrite 2.6//EN"
"http://tuckey.org/res/dtds/urlrewrite2.6.dtd">
<urlrewrite>
<rule>
<from>/viewthread/(/d+).htm$</from>
<to>/viewthread.jsp?id=$1</to>
</rule>
</urlrewrite>
# 去掉这个前面的#,启用它 LoadModule rewrite_module modules/mod_rewrite.so <VirtualHost _default_:80> # 其它的配置数据 RewriteEngine On # 下面三行实现动态解析 RewriteRule ^/viewthread/(/d+).htm$ /viewthread.jsp?id=$1 [L,PT] </VirtualHost>
详细参考这里: http://www.java2000.net/p5422
第三种,最灵活,我一般简单的应用都是用这个实现的。
转载自:老紫竹的专栏