<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure.dtd">

<!-- =============================================================== -->
<!-- Mixin the RewriteHandler                                        -->
<!-- =============================================================== -->


<Configure id="Server" class="org.eclipse.jetty.server.Server">

    <!-- =========================================================== -->
    <!-- configure rewrite handler                                   --> 
    <!-- =========================================================== -->
    <Get id="oldhandler" name="handler"/>

    <Set name="handler">
     <New id="Rewrite" class="org.eclipse.jetty.rewrite.handler.RewriteHandler">
      <Set name="handler"><Ref id="oldhandler"/></Set>
      <Set name="rewriteRequestURI">true</Set>
      <Set name="rewritePathInfo">false</Set>
      <Set name="originalPathAttribute">requestedPath</Set>

      <!-- Add rule to protect against IE ssl bug -->
      <Call name="addRule">
        <Arg>
          <New class="org.eclipse.jetty.rewrite.handler.MsieSslRule"/>
        </Arg>
      </Call>

      <!-- protect favicon handling -->
      <Call name="addRule">
        <Arg>
          <New class="org.eclipse.jetty.rewrite.handler.HeaderPatternRule">
	    <Set name="pattern">/favicon.ico</Set>
	    <Set name="name">Cache-Control</Set>
	    <Set name="value">Max-Age=3600,public</Set>
	    <Set name="terminating">true</Set>
          </New>
        </Arg>
      </Call>


      <!-- use legacy API for some rewrites -->
      <Call name="addRewriteRule">
	<Arg>/some/old/context/*</Arg>
	<Arg>/test/dump/newcontext</Arg>
      </Call>
      <Call name="addRewriteRule">
	<Arg>/test/dump/rewrite/*</Arg>
	<Arg>/test/dump/rewritten</Arg>
      </Call>
      <Call name="addRewriteRule">
	<Arg>/test/dump/rewrite/protect/*</Arg>
	<Arg/>
      </Call>
      <Call name="addRewriteRule">
	<Arg>/test/*</Arg>
	<Arg/>
      </Call>
      <Call name="addRewriteRule">
	<Arg>/*</Arg>
	<Arg>/test</Arg>
      </Call>

      <!-- add a regex rule -->
      <Call name="addRule">
        <Arg>
          <New class="org.eclipse.jetty.rewrite.handler.RewriteRegexRule">
            <Set name="regex">/test/dump/regex/([^/]*)/(.*)</Set>
            <Set name="replacement">/test/dump/$2/$1</Set>
          </New>
        </Arg>
      </Call>
     </New>
    </Set>
    
</Configure>
