seo优化urlrewrite伪静态技术
1.下载urlrewrite-3.2.0.jar
2.在WEB-INF下增加urlrewrite.xml
<?xml version="1.0" encoding="utf-8"?> <!DOCTYPE urlrewrite PUBLIC "-//tuckey.org//DTD UrlRewrite 3.2//EN" "http://tuckey.org/res/dtds/urlrewrite3.2.dtd"> <urlrewrite> <!-- <a href="projects/" >z转换</a> 代码实际去访问/projects/item.jsp--> <rule> <from>^/projects/$</from> <to type="forward">/projects/item.jsp</to> </rule> <rule> <from>^/articles/$</from> <to type="forward">/articles/member_atr.jsp</to> </rule> <!-- $1表示第一个正则表达式 $2-表示第2个-> <rule> <from>^/articles/a-([0-9]+)\.html$</from> <to type="forward">/articles/member_atrdetail.jsp?id=$1</to> </rule> <rule> <note> 将所有.jsp文件映射为.htm </note> <from>^/([_a-zA-Z]+[_0-9a-zA-Z-/]*[_0-9a-zA-Z]+).htm$</from> <to type="forward">/$1.jsp</to> </rule> </urlrewrite>
3.web.xml中配置
<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> <dispatcher>REQUEST</dispatcher> <dispatcher>FORWARD</dispatcher> </filter-mapping>