Redirect xhtml to html

Splash Forums Rewrite Users Redirect xhtml to html

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

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
  • #25351


    We would like to redirect all *.xhtml to *.html

    How would this be possible?

    I tried the following:
    config.addRule().when( Direction.isInbound().and( Path.matches( “{whatever}.xhtml” ) ) ).perform( Redirect.temporary( “{whatever}.html” ))

    Forward works with a join… but not as a redirect, shown before.

    Do you have any solution?


    You want to redirect, not forward? Also, what exactly is not working? Your configuration doesn’t look correct, because {params} don’t match over / by default, additionally…

    If you look at the docs on Redirect, it documents that you must also prepend the Servlet context path:

        * Create an {@link Operation} that issues a permanent {@link Redirect} ( 301
        * {@link HttpServletResponse#SC_MOVED_PERMANENTLY} ) to the given location. If the given location is not the same as
        * {@link HttpServletRewrite#getAddress()}, this will change the browser {@link URL} and result in a new request.
        * <p>
        * Note that in order to redirect to a resource within the {@link ServletContext}, you must prepend the
        * {@link ServletContext#getContextPath()}.
        * <p>
        * For example:<br/>
        * <code>
        *    Redirect.permanent(contextPath + &quot;/example/location.html&quot;) <br>
        * </code>
        * <p>
        * The given location may be parameterized:
        * <p>
        * <code>
        *    /store/global
        *    /store/{category} <br>
        *    /store/{category}/item/{itemId} <br>
        *    ...
        * </code>
        * <p>
        * @param location {@link ParameterizedPattern} specifying the target location.
        * @see ConfigurationRuleParameterBuilder#where(String)
       public static Redirect permanent(final String location)

    ServletContext.getContextPath() will be available from the context method parameter in your configuration provider.


    Additionally, I think you can still use a Join for this:


    This should do what you want.



    Also with the slash in the beginning it does not work:
    config.addRule().when( Direction.isInbound().and( Path.matches( “/{whatever}.xhtml” ) ) ).perform( Redirect.temporary( “/{whatever}.html” ))

    What we need is to hide the .xhtml files from the user instead show html to do so and to not always do forwards when user bookmarks => redirects prevent them from adding bookmarks in the first place, so we need/want to do redirects.

    what i want is to redirect the followings:

    /aaa/bbb.xhtml to /aaa/bbb.html
    /aaa.xhtml to /aaa.xhtml

    no matter whatever is in front of xhtml just redirect it to html

    hope i could explain a bit clearer…


    Do you actually have any HTML or XHTML files in your system?



    On server we have xhtml files,

    but we want the user to access html files.

    in the url ALWAYS should stay html and never xhtml

    so from something.xhtml he gets redirected to something.html



    Which works, but does not do a redirect 🙁 => it’s a forward


    Yes, it does a Forward from “.html” -> “.xhtml”, but it *does* Redirect from “.xhtml” -> “.html” as well.

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

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

Comments are closed.