Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

How to move or relocate a Context.

The MovedContextHandler may be used to relocate or redirect a context that has changed context path and/or virtual hosts.

You can configure it to permanently redirect the old url to the new url. Jetty sends a Http Status code of 301 to the browser with the new url. Alternatively, you can make it non-permanent, in which case Jetty sends a 302 Http Status code along with the new url.

In addition, like any other context, you can configure a list of virtual hosts.

The sample context configuration below redirects the /foo context to / with a permanent redirection, while preserving pathinfo and query strings. This file would be put into $JETTY_HOME/contexts directory:

Code Block
xml
xml
titlemove-my-context.xml
<?xml version="1.0"  encoding="ISO-8859-1"?>
<!DOCTYPE Configure PUBLIC "-//Mort Bay Consulting//DTD Configure//EN" "http://jetty.mortbay.org/configure.dtd">

<Configure class="org.mortbay.jetty.handler.MovedContextHandler">
  <Set name="contextPath">/foo</Set>
  <Set name="newContextURL">/</Set>
  <Set name="permanent">true</Set>
  <Set name="discardPathInfo">false</Set>
  <Set name="discardQuery">false</Set>

  <Set name="virtualHosts">
    <Array type="String">
          <Item>209.235.245.73</Item>
          <Item>127.0.0.73</Item>
          <Item>acme.org</Item>
          <Item>www.acme.org</Item>
          <Item>server.acme.org</Item>
    </Array>
  </Set>

</Configure>



Back to FAQ


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