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
The RewriteHandler matches a request against a set of rules, and modifies the request accordingly for any rules that match. The most common use is to rewrite request URIs, but it is capable of much more: rules can also be configured to redirect the response, set a cookie or response code on the response, modify the header, etc.
Maven artifact: org.eclipse.jetty:jetty-rewrite
$ java -jar start.jar --add-to-startd=rewrite
If you are running the standard Jetty distribution with the sample test webapp, there will be a demo of the rewrite module at http://localhost:8080/test/rewrite/
The rewrite module enables the following jetty xml config file on the execution path:
As the commented out code shows, you configure the RewriteHandler by adding various rules.
There is an example of rules
configuration in the standard distribution in the
There are several types of rules that are written extending useful base rule classes.
Matches against the request URI using the servlet pattern syntax.
Adds a cookie to the response.
Adds/modifies a header in the response.
Redirects the response.
Sends the response code (status or error).
Rewrite the URI by replacing the matched request path with a fixed string.
Matches against the request URI using regular expressions.
Match against request headers. Match either on a header name + specific value, or on the presence of a header (with any value).
Set the scheme on the request (defaulting to https).
Oddball rules that defy classification.
Groups rules together. The contained rules will only be processed if the conditions for the RuleContainer evaluate to true.
Groups rules that apply only to a specific virtual host or a set of virtual hosts