1 Reply Latest reply on Jan 14, 2015 1:15 PM by Karthik Vasishta Ramesh

    configure undertow (wildfly 8.1.0.Final) to rewrite angularjs path

    fiorenzo pizza Newbie



      i would like to use undertow handler to rewrite my angularjs urls.

      In a angularjs single page app, the paths are in form of  /#/page_name, for example:






      I would like match paths like:

      https://we.getdat.es/contact to https://we.getdat.es/#/contact


      I would like to have in undertow a configuration file similar to the one of apache mod_rewrite, that i found in a google newsgroup:


      RewriteEngine on
      # if a directory or a file exists, use it directly
      RewriteCond %{REQUEST_FILENAME} -s [OR]
      RewriteCond %{REQUEST_FILENAME} -l [OR]
      RewriteCond %{REQUEST_FILENAME} -d
      RewriteCond %{REQUEST_URI} !/api
      RewriteRule ^.*$ - [NC,L]

      # otherwise forward it to index.html
      RewriteRule ^app/(.*) /app/#/$1 [NC,L]



      So i started to add a undertow configuration file 'undertow-handlers.conf' to my ROOT.war/WEB-INF/ folder, with the following line:

      regex['^/index\.html/(.*)'] -> rewrite['/index.html/#/${1}']


      But the hashtag character seems to mess things up.

      Beside I miss the rules to not rewrite:

      -  if a directory or a file exists, use it directly

      - the path to rest resources


      Can someone help me to configure the undertow?

      This configuration file would be very useful to deploy java ee7 web apps with angularjs like front end, on openshift.


      Thanks in advance



      Fiorenzo Pizza