OCPsoft URL-Rewriting Framework
Java Ruby JavaScript HTML Other
Failed to load latest commit information.
addressbuilder Fix #213: Performance issue with URLBuilder Jul 16, 2016
annotations-api [maven-release-plugin] prepare for next development iteration May 22, 2015
annotations-impl Disabled test which doesn't work anymore because we cannot mock stati… Mar 25, 2016
api-el [maven-release-plugin] prepare for next development iteration May 22, 2015
api-servlet Implemented #195: Fix crash on {} characters in inbound URLs. Also cl… Jul 16, 2016
api-tests Added the ability to tell if a condition has been negated Nov 3, 2015
api Fix bug where all event rules are logged as errors Jul 19, 2016
config-annotations junit.framework.* -> org.junit.* May 28, 2015
config-jodatime junit.framework.* -> org.junit.* May 28, 2015
config-prettyfaces-tests Test for #224: Problem with # character in request parameters Jul 16, 2016
config-prettyfaces Implemented #195: Fix crash on {} characters in inbound URLs. Also cl… Jul 16, 2016
config-proxy [maven-release-plugin] prepare for next development iteration May 22, 2015
config-servlet-tests [maven-release-plugin] prepare for next development iteration May 22, 2015
config-servlet Fix #213: Performance issue with URLBuilder Jul 16, 2016
config-tuckey Attempt to fix release build Nov 5, 2015
distribution [maven-release-plugin] prepare for next development iteration May 22, 2015
documentation Fixed bad code in install.asciidoc (#237) Jun 27, 2016
examples [maven-release-plugin] prepare for next development iteration May 22, 2015
impl-servlet-2.5 [maven-release-plugin] prepare for next development iteration May 22, 2015
impl-servlet-3.0 [maven-release-plugin] prepare for next development iteration May 22, 2015
impl-servlet-tests [maven-release-plugin] prepare for next development iteration May 22, 2015
impl-servlet Fix #213: Performance issue with URLBuilder Jul 16, 2016
impl-tests junit.framework.* -> org.junit.* May 28, 2015
impl [maven-release-plugin] prepare for next development iteration May 22, 2015
integration-cdi-tests [maven-release-plugin] prepare for next development iteration May 22, 2015
integration-cdi Typo Jun 1, 2015
integration-faces-tests Looks like JSessionIdTest doesn't work on Wildfly (and AS7, and Glass… May 29, 2015
integration-faces Implemented #195: Fix crash on {} characters in inbound URLs. Also cl… Jul 16, 2016
integration-gwt junit.framework.* -> org.junit.* May 28, 2015
integration-spring junit.framework.* -> org.junit.* May 28, 2015
rewrite-servlet [maven-release-plugin] prepare for next development iteration May 22, 2015
security-integration-shiro [maven-release-plugin] prepare for next development iteration May 22, 2015
showcase [maven-release-plugin] prepare for next development iteration May 22, 2015
test-base [maven-release-plugin] prepare for next development iteration May 22, 2015
test-harness Updated to Wildfly 8.2.0.Final May 29, 2015
transform-less Tests ignored on Wildfly for now (see #211) May 29, 2015
transform-markup junit.framework.* -> org.junit.* May 28, 2015
transform-minify Attempt to fix release build Nov 5, 2015
transform [maven-release-plugin] prepare for next development iteration May 22, 2015
.gitignore Add dependency-reduced-pom.xml to .gitignore Jul 19, 2016
.travis-deploy.sh Skip GPG signing when doing snapshot deployment Jan 7, 2015
.travis-settings.xml Snapshot deployment Jan 6, 2015
.travis.yml Dropped Java 6 support Jul 22, 2016
CHANGELOG.md changelog again Jul 24, 2012
LICENSE Initial import Jun 24, 2011
NOTICE rewrite-servlet and distribution modules working Apr 4, 2012
README.md Add Gitter badge Jun 4, 2016
ocpsoft-eclipse-code-format.xml Added code style format profile for Eclipse Aug 5, 2011
pom.xml Updated to new logging version Jul 24, 2016

README.md

Rewrite Build Status

Join the chat at https://gitter.im/ocpsoft/rewrite

A highly configurable URL-rewriting tool for Java EE 6+ and Servlet 2.5+ applications, supporting integration with:

  • CDI
  • Spring DI
  • JodaTime configuration
  • Tuckey.org URLRewriteFilter configuration
  • JavaServer Faces (JSF)
  • JavaServer Pages (JSP)
  • Struts
  • Wicket
  • Grails
  • Spring Roo
  • Spring Web Flow
  • Any servlet & web framework!
  • All major servlet containers and application servers

Get Help

Get Started

  1. It is recommended but not required to remove other URL-rewriting tools from your application before using Rewrite. If you choose to leave them in place, weird things may happen, be warned.

  2. Include OCPSoft Rewrite in your application's POM file:

    <dependency>
       <groupId>org.ocpsoft.rewrite</groupId>
       <artifactId>rewrite-servlet</artifactId>
       <version>${rewrite.version}</version>
    </dependency>
    
  3. Add a configuration provider implementing the 'org.ocpsoft.rewrite.config.ConfigurationProvider' interface, or extending from the abstract HttpConfigurationProvider class for convenience:

    package com.example;
    
    @RewriteConfiguration
    public class ExampleConfigurationProvider extends HttpConfigurationProvider
    {
    
       @Override
       public int priority()
       {
         return 10;
       }
    
       @Override
       public Configuration getConfiguration(final ServletContext context)
       {
         return ConfigurationBuilder.begin()
           .defineRule()
             .when(Direction.isInbound().and(Path.matches("/some/page/{p}/")))
             .perform(Forward.to("/new-page/{p}.html"));
        }
    }
    
  4. You must either annotate your ConfigurationProvider class with the @RewriteConfiguration annotation, OR create a file named: '/META-INF/services/org.ocpsoft.rewrite.config.ConfigurationProvider' which contains the fully qualified name of your ConfigurationProvider implementation:

    /META-INF/services/org.ocpsoft.rewrite.config.ConfigurationProvider
    ---
    com.example.ExampleConfigurationProvider
    
  5. Add rules to your configuration. Condition objects such as 'Direction.isInbound()' and 'Path.matches(...)' can be found in the 'org.ocpsoft.rewrite.config.' and 'org.ocpsoft.rewrite.servlet.config.' packages.

  6. Consider using Rewrite extensions for extra power:

  7. Run your application!

FEEDBACK

This project is looking for your feedback! What would make your task easier? How can we simplify this experience?

TODO's

  • Continue simplification of Configuration objects and convenience APIs.

  • Implement additional xml & file-based configuration support.

  • Implement http://localhost:8080/rewrite-status monitoring tool