mapping welcome file to prettified url

Splash Forums PrettyFaces Users mapping welcome file to prettified url

This topic contains 11 replies, has 3 voices, and was last updated by  Christian Kaltepoth 5 years, 5 months ago.

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #18116

    Serkan Durusoy
    Participant

    Hi Everyone,

    I have a requirement that I cannot seem to figure out how to fullfil.

    The project is configured to have welcome file as index.xhtml

    Faces servlet mapping and the default suffix are configured for *.xhtml

    We are on Tomcat 7 and servlet 3.0 with mojarra 2.1.4

    We have a url mapping of pattern “/” to view-id “/index.xhtml”

    What I want is, if a visitor tries to access mydomain/myapp/index.xhtml, I want the visible url to be changed as mydomain/myapp/ or mydomain/myapp

    To accomplish this, we used to have a rewrite rule to match “index.xhtml” to substitute “/” when we were on 3.3.0

    We upgraded to 3.3.2 and it no longer works

    Does anyone have any idea about what I can do?

    #21799

    Serkan Durusoy
    Participant

    I read somewhere that 3.3.2 improves on 3.3.0 to eliminate some cases that end up in infinite loops. Perhaps that explains the behaviour change there.

    Anyway, my question actually boils down to this:

    I would like mydomain/myapp/index.xhtml to redirect to mydomain/myapp/ (the trailing slash is not important here for me, as long as it is consistent) while index.xhtml is also the welcome file.

    Is there a way I can accomplish this?

    #21800

    Hey Serkandurusoy,

    Could you please post your existing code when reporting issues like this? It helps us to understand what you are doing and see what might actually be wrong; hard to know what’s wrong otherwise.

    It should still be possible to do this. Not exactly sure what would have changed.

    Post your relevant lines of config and we’ll see what’s happening.

    ~Lincoln

    #21801

    Serkan Durusoy
    Participant

    Hi Lincoln,

    Thanks for your interest. Please forget about any “issue” that I described. What I actually want to know is this:

    is there a way to make sure when a visitor directly accesses the welcome file “index.xhtml”, he is redirected to “/”

    What I’m trying to accomplish is to avoid:

    http://mydomain/myapp/index.xhtml

    http://mydomain/myapp/

    to both get into the google index. In fact, I don’t want anyone to know about index.xhtml.

    Can I somehow use prettyfaces for this purpose?

    Thanks,

    Serkan

    #21802

    In theory this should be possible with a rewrite rule like this:

    <rewrite match="/index.xhtml" substitute="/" redirect="301"/>

    However there is currently a bug in PrettyFaces 3.3.2 that prevents this from working correctly. I’m currently working on fixing this. I’ll come back to you as soon as I committed the fix to the snapshots.

    #21803

    Serkan Durusoy
    Participant

    Hi Christian,

    Actually <rewrite match=”/index.xhtml” substitute=”/” redirect=”301″/> used to work in 3.3.0 and in 3.3.2 it causes an infinite redirect loop.

    Since you’re going to be committing the fix to this in the snapshots, I need to ask this:

    Are the snapshots safe to use in a production environment?

    Thanks,

    Serkan

    #21804

    Yeah, I know that it worked in 3.3.0. But the fact that it worked was actually a side-effect of some other bug that we fixed in 3.3.2! :)

    I think it’s very safe to use the snapshots of the 3.x branch because there is currently no active development done on 3.x. We are currently focusing on 4.x and 3.x is a “bugfix-only” branch!

    Christian

    #21805

    Serkan Durusoy
    Participant

    Hi Christian,

    Thanks. What is the version for the v3 snapshot? I can’t figure out what to write in pom.xml

    Serkan

    #21806
    #21807

    I just committed the fix and pushed it upstream. Could you give 3.3.3-SNAPSHOT a try?

    This should work now with:

    <rewrite match="/index.xhtml" substitute="/" redirect="301"/>

    #21808

    Serkan Durusoy
    Participant

    Hi Christian,

    I just tested it and it works like a charm.

    Thank you very much.

    Looking forward to the release of version 4 :)

    #21809

    Great! Thanks for testing! I think we will release 3.3.3 in a few weeks. :)

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

You must be logged in to reply to this topic.

Comments are closed.