This component acts as a servlet filter and redirects requests.
It matches the request based on a perl-like regular expression.
It then forwards it as you've specified.
The jar files and documentation are available at http://urlrewrite.dev.java.net
The jar files are also in the smallx samples I'll be distributing.
Here is an example configuration:
Add this to the WEB-INF/web.xml file:
<filter> <filter-name>UrlRewriteFilter</filter-name> <filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class> <!-- uncomment me to turn on debugging <init-param> <param-name>logLevel</param-name> <param-value>DEBUG</param-value> </init-param> --> <init-param> <param-name>confReloadCheckInterval</param-name> <param-value>60</param-value> </init-param> </filter> <filter-mapping> <filter-name>UrlRewriteFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
The WEB-INF/urlrewrite.xml file:
<!DOCTYPE urlrewrite PUBLIC "-//tuckey.org//DTD UrlRewrite 2.0//EN" "urlrewrite.dtd"> <urlrewrite> <rule> <from>(.+)/site.css$</from> <to>/site.css</to> </rule> <rule> <from>/(.+)/mydoc.xml</from> <to>/mydoc.xml?view=$1</to> </rule> </urlrewrite>