Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jetty-users] Jetty 9 Redirect from Root to Sub-Directory.

Hi,
 
            I have downloaded Jetty 9, and I am curious how to do a redirect from the root to a particular sub directory. I basically want to redirect from http://localhost:7070/ to http://localhost:7070/solr/. I looked at http://www.eclipse.org/jetty/documentation/current/jetty-handlers.html#rewrite-handler and I added the following to the bottom of my jetty.xml.
 
<!-- create and configure the rewrite handler -->
    <New id="Rewrite" class="org.eclipse.jetty.rewrite.handler.RewriteHandler">
      <Set name="rewriteRequestURI">true</Set>
      <Set name="rewritePathInfo">false</Set>
      <Set name="originalPathAttribute">requestedPath</Set>
 
      <!-- redirect the response. This is a redirect which is visible to the browser.
           After the redirect, the browser address bar will show /redirected -->
      <Call name="addRule">
        <Arg>
          <New class="org.eclipse.jetty.rewrite.handler.RedirectPatternRule">
            <Set name="pattern">^$</Set>
            <Set name="replacement">/solr</Set>
          </New>
        </Arg>
      </Call>
    </New>
           
            <!-- add the rewrite handler to the server -->
    <Set name="handler"><Ref id="Rewrite" /></Set>
 
 Is this pattern "^$" correct for my situation? Thank you for all your help.
 
O. O.

Back to the top