Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: a777ad1e89f41cb8b71202c571d1394ec16d79b9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?xml version="1.0"?>
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "http://www.eclipse.org/jetty/configure_9_3.dtd">

<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 refid="oldhandler"/></Set>
      <Set name="rewriteRequestURI">true</Set>
      <Set name="rewritePathInfo">false</Set>
      <Set name="originalPathAttribute">requestedPath</Set>

      <Set name="rules">
          <Array type="org.eclipse.jetty.rewrite.handler.Rule">

            <!-- add a response rule -->
            <!--
            <Item>
              <New id="response" class="org.eclipse.jetty.rewrite.handler.ResponsePatternRule">
                <Set name="pattern">/rewrite/session/</Set>
                <Set name="code">401</Set>
                <Set name="reason">Setting error code 401</Set>
              </New>
            </Item>
             -->

            <!-- add a simple redirect -->
            <!--
            <Item>
              <New id="redirect" class="org.eclipse.jetty.rewrite.handler.RedirectPatternRule">
                <Set name="pattern">/redirect/*</Set>
                <Set name="location">/tests/</Set>
              </New>
            </Item>
             -->

            <!-- add a regex rewrite redirect -->
            <Item>
              <New id="redirect" class="org.eclipse.jetty.rewrite.handler.RedirectRegexRule">
                <Set name="regex">/redirect/(.*)</Set>
                <Set name="replacement">/tests/$1</Set>
              </New>
            </Item>
          </Array>
        </Set>
      </New>
    </Set>

</Configure>

Back to the top