Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

The RewriteHandler processes a list of rules and checks each in turn, ignoring those that don't match the request. It then applies the ones that match. It is inspired by Apache's mod-rewrite, but can do many things aside from rewriting URIs. Rules can also be grouped into RuleContainers, for example to restrict a set of rule to a specific virtual host

Rule List

A. PatternRule

Abstract rule to use as a base class for rules that use a PathMap for pattern matching. It uses the servlet pattern syntax. Below are known subclasses of PatternRule, and descriptions of their actions:

  1. CookiePatternRule
    Adds a cookie to the response.
  2. HeaderPatternRule
    Adds/modifies a header in the response.
  3. RedirectPatternRule
    Redirects the response.
  4. ResponsePatternRule
    Sends the response code (status or error).
  5. RewritePatternRule
    Rewrite the URI by replacing the matched request path with a fixed string.

B. RegexRule

Abstract rule to use as a base class for rules that match with a regular expression. Below are known subclasses of RegexRule, and descriptions of their actions:

  1. RewriteRegexRule
    Rewrite the URI by matching with a regular expression. (The replacement string may use $n to replace the nth capture group.)

C. HeaderRule

Abstract rule to use as a base class for rules that match against request headers. It can match either on a headername+specific value, or on the presence of a header (with any value). Available from Jetty 6.1.12 and Jetty 7.0.0pre3 onwards. Below are known subclasses of HeaderRule, and descriptions of their actions:

  1. ForwardedSchemeHeaderRule
    Set the scheme on the request (defaulting to https).

D. Others

  1. MsieSslRule
    Disables the keep alive for SSL from IE5 or IE6.
  2. LegacyRule
    Rule implementing the legacy API of RewriteHandler

RuleContainer List

Base container to group rules. Can be extended so that the contained rules will only be processed if certain conditions apply. Available from Jetty 6.1.12 and Jetty 7.0.0pre3 onwards

  1. VirtualHostRuleContainer
    Groups rules that apply only to a specific virtual host or a set of virtual hosts
  2. LowThreadsRuleContainer
    Contains rules that are executed when the thread pool is low on threads. For example, you can choose to or send an error code or redirect the response.

Sample Configuration

There is a sample file provided. To use this configuration, install the rewrite handler, so that it will copy files to the proper locations,

Code Block
cd $JETTY_HOME/contrib/jetty-rewrite-handler
mvn install

then include the configuration file during jetty startup:

Code Block
java -jar start.jar etc/jetty.xml etc/jetty-rewrite.xml
Contact the core Jetty developers at www.webtide.com
private support for your internal/customer projects ... custom extensions and distributions ... versioned snapshots for indefinite support ... scalability guidance for your apps and Ajax/Comet projects ... development services from 1 day to full product delivery