Tuckey Logo Url Rewrite Filter

Based on the popular and very useful mod_rewrite for apache, UrlRewriteFilter is a Java Web Filter for any J2EE compliant web application server (such as Resin, Orion or Tomcat), which allows you to rewrite URLs before they get to your code. It is a very powerful tool just like Apache's mod_rewrite.

URL rewriting is very common with Apache Web Server (see mod_rewrite's rewriting guide) but has not been possible in most java web application servers. The main things it is used for are:

UrlRewriteFilter uses an xml file, called urlrewrite.xml (it goes into the WEB-INF directory), for configuration. Most parameters can be Perl5 style Regular Expressions or Wildcard Expressions. This makes it very powerful indeed.

Source hosted at code.google

See the manual for more information. You may also find the javadoc useful.

Download & Installation

Binaries

Stable 2.6
urlrewritefilter-2.6.zip
200kb - md5

Beta 3.1
urlrewritefilter-3.1.0.zip
134kb changelog

  1. Download the zip and extract it into your context's directory ie, so that urlrewrite.xml goes into the WEB-INF directory.
  2. Add the following to your WEB-INF/web.xml (add it near the top above your servlet mappings (if you have any)): (see filter parameters for more options)
    
            <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>
            
  3. Add your own configuration to the WEB-INF/urlrewrite.xml that was created.
  4. Restart the context.

You can visit http://127.0.0.1:8080/rewrite-status (or whatever the address of your local webapp and context) to see output (note: this page is only viewable from localhost).

Source

Stable 2.6
urlrewritefilter-2.6-src.zip
1.5mb - md5

Beta 3.1
urlrewritefilter-3.1.0-src.zip
1.5mb - changelog

Mentions

This filter has been mentioned at: Transparently Feedburning Pebble with UrlRewriteFilter, heute-morgen.de (parametrized View State with JSF), Erik Isaksson's Blog (sample rules), Magician (use with forumnuke, in Chinese), Russell Beattie's Notebook.

Donations supporting the future development of UrlRewriteFilter are greatly appreciated. If you are using it in a commercial site please consider donating.




Copyright 2005 Paul Tuckey