title: Rewriting paths with undertow-handlers.conf doesn't work as expected
body: <h1>Background</h1>
  
  <p>JBoss 7.1.5 EAP back-end with an Angular 7 UI.</p>
  
  <p>I need to make JBoss aware of the UI's routes, but rewrite them all to the UI's index page for routing by Angular.</p>
  
  <p>The project is structured thus:</p>
  
  <pre><code>webapp/
    WEB-INF/
      undertow-handlers.conf
      web.xml
      ...etc
    login/
      background.jpg
    login.jsp
    index.jsp
  
    assets/*
    ...html
    ...js
    ...css
  </code></pre>
  
  <p><code>index.jsp</code> simply <code>response.sendRedirect("index.html")</code>s, where index.html is part of the assets produced by the Angular CLI. JavaScript and HTML is served from <code>webapp/</code>, images from <code>webapp/assets/</code>.</p>
  
  <h1>Configuration</h1>
  
  <p>From <code>standalone-full.xml</code></p>
  
  <pre><code>&lt;subsystem xmlns="urn:jboss:domain:undertow:4.0"&gt;
      &lt;buffer-cache name="default"/&gt;
      &lt;server name="default-server"&gt;
          &lt;http-listener name="http" socket-binding="http" redirect-socket="https"/&gt;
          &lt;host name="default-host" alias="localhost,workstation"&gt;
              &lt;location name="/" handler="welcome-content"/&gt;
              &lt;filter-ref name="request-dumper"/&gt;
          &lt;/host&gt;
      &lt;/server&gt;
      &lt;servlet-container name="default"&gt;
          &lt;jsp-config x-powered-by="false"/&gt;
          &lt;websockets/&gt;
      &lt;/servlet-container&gt;
      &lt;handlers&gt;
          &lt;file name="welcome-content" path="${jboss.home.dir}/welcome-content"/&gt;
      &lt;/handlers&gt;
      &lt;filters&gt;
          &lt;filter name="request-dumper" module="io.undertow.core" class-name="io.undertow.server.handlers.RequestDumpingHandler"/&gt;
      &lt;/filters&gt;
  &lt;/subsystem&gt;
  </code></pre>
  
  <p>and</p>
  
  <pre><code>&lt;subsystem xmlns="urn:jboss:domain:web:2.2" default-virtual-server="default-host" native="false"&gt;
      &lt;connector name="http" protocol="HTTP/1.1" scheme="http" socket-binding="http"/&gt;
      &lt;virtual-server name="default-host"&gt;
          &lt;alias name="localhost"/&gt;
          &lt;alias name="workstation"/&gt;
      &lt;/virtual-server&gt;
  &lt;/subsystem&gt;
  </code></pre>
  
  <p>With the above configuration, I see the expected server log:</p>
  
  <pre><code>[org.wildfly.extension.undertow] (ServerService Thread Pool -- 84) WFLYUT0021: Registered web context: '/' for server 'default-server'
  </code></pre>
  
  <p>And I can access the site's login page, and the URI <code>/</code> serves the main angular index page and assets as expected.</p>
  
  <h1>Problem</h1>
  
  <p>What I need is for paths in this context (like <code>/base</code> or <code>/shop/60</code>) to be handled by Angular, so redirected to index.</p>
  
  <p>As a simple test based on <a href="https://stackoverflow.com/questions/44978074/how-do-i-configure-undertow-handlers-to-support-proper-rewriting-for-spa-bookmar">this answer</a>, I have tried this single rule in <code>WEB-INF/undertow-handlers.conf</code>:</p>
  
  <pre><code>exists(%{RELATIVE_PATH}) -&gt; done
  path-prefix('/') -&gt; rewrite('/');
  </code></pre>
  
  <p>but <em>it seems to do nothing at all</em> as I get a 404.</p>
  
  <p>I've tried <code>-&gt; rewrite('/index.html')</code> and <code>-&gt; rewrite('/index.jsp')</code> to no avail.</p>
  
  <p>The file is clearly being read, though, because if I put garbage into the file it throws an exception in the server log.</p>
  
  <pre><code>UT000045: Error parsing predicated handler string Invalid expression:
  # path('/base') -&gt; rewrite('/')
  </code></pre>
  
  <p>What have I missed?</p>
  
  <p>I'm <em>quite</em> a neophyte to JBoss and the whole Undertow ecosystem; please let me know what other details I should add to this question.</p>
  
  <h1>Curiosity</h1>
  
  <p>With request dumper activated, I see a single initial request to <code>/</code> made by JBoss (<code>User-Agent=Java/1.8.0_181</code>) immediately after booting, but when I navigate to <code>/</code> from a browser, I don't see that request in the dump. But I do see the failed request for <code>/base</code>. Why is that?</p>