Reply To: Rewrite configuration is not working

Splash Forums Rewrite Users Rewrite configuration is not working Reply To: Rewrite configuration is not working

#28374

I just had a look at your app. The sample was very helpful. Two things I would like to mention.

First you really don’t need to add any configuration to your web.xml for Rewrite to work correctly. This is done automatically. So you can remove the Rewrite filter and listener configuration.

So real problem seems to be your context path. You defined a custom context path with jboss-web.xml. This file contains a context path definition like this:

<context-root>/dummy/</context-root>

The problem here is that this is actually not a valid context path. Or let’s call it “uncommon”. The trailing slash is the problem. JBoss seems to return exactly this string via request.getContextPath(), but the result of this method usually doesn’t contain trailing slashes. And that’s why Rewrite gets confused.

To fix the problem, simply replace the context path definition with this (no trailing slash):

<context-root>/dummy</context-root>

And now your app works. At least it does with Wildfly 14. That was the version I tested with.