Simple question – remove prefix from URLs

Splash Forums Rewrite Users Simple question – remove prefix from URLs

This topic contains 9 replies, has 2 voices, and was last updated by  Lincoln Baxter III 8 years, 7 months ago.

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
  • #24164



    I have a simple question, but can not find a solution. Assume, all my XHTML files are located in webapp under the folder “mod”. I would like to avoid the need to type /mod/… in URLs. How can I rewrite URLs with the Rewrite, so that all requests get a prefix “mod” when resolving against real paths? For instance, when somebody types as URL


    it should be resolved (mapped) to


    I’ve tried with

    public Configuration getConfiguration(ServletContext context)
        return ConfigurationBuilder.begin().addRule(Join.path("/{tail}").to("/moda/{tail}")).where("tail")

    but no luck. Can one help me? Thanks in advance and sorry for this stupid question.



    What I get as result for this mapping is 404. Furthermore, I see URLs like this one


    windowId is CDI specific. That’s ok. But twice page=index.html is something weird. Is this caused by Rewrite?



    I found that there is a problem even without Configuration when Rewriter with JSF und CDI modules is in the classpath. We get logged in Principal object from the request object. Principal object is put into HttpRequest by a special security filter. When Rewriter with JSF / CDI modules is added to the project (only dependencies), the Principal object is null (and we get NPE). Any ideas?

    • This reply was modified 8 years, 7 months ago by  Oleg.


    Solved by configuring RewriteFilter manually in web.xml as a first filter, before all other filters. This takes precedence over web-fragment.xml in Rewrite JAR file.


    Hey Oleg,

    Thanks for posting your solution. I’m sorry you had trouble, but glad you got it figured out!



    Actually, I think this is a bug with the CDI integration that we may need to work on. CDI BeanManagers are tricky to get a hold of 😉



    Yes, I think this is a bug with CDI integration.

    It works with PrimeFaces <p:button …/> (full page GET request).
    It works with <p:commandButton …/> (AJAX request per default)
    It DOESN’T WORK with <p:commandButton ajax=”false” …/> (full page POST request).

    In the third case I can see added windowId with every full page POST request. E.g. after 3 requests:



    When you say it doesn’t work, what is the problem exactly?

    Is the problem the extra parameters, or is the problem something that is actually technically not working at all?




    It works fine technically. Extra CDI parameters are annoying :-). I could avoid Rewrite parameters (in the example &page=index.html&page=index.html) by adding rules without binding (you know what I mean), but CDI parameters are still here.


    Could you upload a sample app that reproduces this on an EE appserver like JBoss/Wildfly/GlassFish ? Or even better, write a Rewrite test case? Either one.

    I’d like to dig into this a bit deeper.


Viewing 10 posts - 1 through 10 (of 10 total)

The forum ‘Rewrite Users’ is closed to new topics and replies.

Comments are closed.