<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE urlrewrite PUBLIC "-//tuckey.org//DTD UrlRewrite 4.0//EN"
        "http://www.tuckey.org/res/dtds/urlrewrite4.0.dtd">
<urlrewrite decode-using="null">

  <rule>
    <note>
     Ensure that URLs ending with .gwtrpc are not modified.
     Note: Not needed with XWiki 9.7+ since the GWT editor has been removed.
    </note>
    <from>^/(.*)\.gwtrpc$</from>
    <to type="forward" last="true">-</to>
  </rule>

  <rule>
    <note>
      Ensure that URLs that must not be served by the Struts Servlet are not modified.
    </note>
    <from>^/((bin|resources|skins|asyncrenderer|rest|webdav|xmlrpc|wiki|jcaptcha|webjars)/(.*)|robots\.txt)$</from>
    <to type="forward" last="true">-</to>
  </rule>

  <rule>
    <note>
      For all other URLs we prepend the "/bin/" prefix so that they get routed to the XWiki Action Servlet.
    </note>
    <from>^/(.*)$</from>
    <to type="forward">/bin/$1</to>
  </rule>

  <outbound-rule>
    <note>
      Rewrite outbound URLs to remove the "/bin" part when there are two paths after it.
    </note>
    <from>/bin/(.*)/(.*)$</from>
    <to>/$1/$2</to>
  </outbound-rule>

  <outbound-rule>
    <note>
      Rewrite outbound URLs to remove the "/bin" part when there's a single path after it.
    </note>
    <from>/bin/(.*)$</from>
    <to>/$1</to>
  </outbound-rule>

  <outbound-rule>
    <note>
      Rewrite outbound URLs to remove the "/bin" part it's the last path.
    </note>
    <from>/bin$</from>
    <to>/</to>
  </outbound-rule>

</urlrewrite>
